September 13, 2017

What is a Type Error?

The top comment by /u/staticassert in a Reddit thread on type systems makes an interesting point, one that I made in the past myself: what is a type error? I read those types (pun intended) of threads often enough, and one recurring argument often made by people who doubt the benefits of type systems goes like this: “I rarely make errors that the type checker would catch; my bugs are logic in nature. ... Read more

September 6, 2017

A Simple Tip to Improve Rust Program Speed

I am on vacation this week, so I decided to dig out a backtracking Sudoku solver I wrote last summer and see what I could do to improve its performance. A couple of changes to the data structures and the algorithm yieled an important speed-up. Previously, I had used a BTreeSet to store the list of candidates for a cell; I now use a u32 to represent a set of 9 elements. ... Read more

September 3, 2017

My Review of The Talos Principle

Now that I have a slightly more powerful computer, I was finally able to play through The Talos Principle and its DLC, The Road to Gehenna. [Spoilers below] The gameplay is mostly about solving problems by using some items. You have jammers that can open doors, disable bombs and guns; boxes to hold down buttons and to increase the height of an item; connectors that relay a signal from an emitter to receivers and can open doors; fans to elevate yourself or an object; etc. ... Read more

August 7, 2017

Speedrunning a Compiler

At AdGear, the developers typically end their week at “Friday Not Friday”, a team activity from 4pm to 5pm. One person gives a presentation on any technical subject while the others listen and sip a beer to wind down before the week-end. Last week, I gave a demonstration that I called “Speedrunning a Compiler”. I wanted to show my colleagues the basics of writing a compiler, and I thought it would be more instructive if they saw code rather than an abstract flowchart. ... Read more

April 17, 2017

Less intrusive color theme

The purpose of syntax highlighting is to draw attention to certain parts of the code: it helps us to identify when a comment or a string literal is not properly terminated, when a keyword is misspelled, or when an escape sequence is invalid. Lately, I find that editors colorize too many elements and use too many colors. (This is a recently-acquired annoyance; maybe age and worse eyesight have something to do with it? ... Read more

April 13, 2017

Functional Queues

First-in first-out queues are a data structure used in many algorithms (including my favorite one—breadth-first search) and as a building block for complex functionality, the operations on queues should be as efficient as possible. This can be a bit of a challenge in a functional language: the bread-and-butter data structure of functional programming, the list, supports fast insertion and deletion at the head—ideal for enqueuing or dequeuing respectively—but operations at the other end of the list take O(n) time in the length of the list. ... Read more

April 7, 2017

Being a T.A.

Being a teaching assistant is a job that most graduate students are asked—pressured even—to do. During my time at McGill, I was a T.A. three times: twice for the introduction to compiler design class (taught by my adviser), and once for a functional programming class. It was difficult, time-consuming, and not well paid, yet being a T.A. was the best job I’ve ever had. I’ve had many bad T.A.’s when I was an undergrad; absent from the message boards, with a poor understanding of the subject, and confusing in their explanations, they make hard classes more difficult and bad classes unbearable. ... Read more

March 27, 2017

Journalistic Writing Exercises 1

I recently purchased Journalistic Writing by Robert Knight. I’m not a journalist, but I’m sure some of his lessons transfer to other areas of non-fiction writing. At the end of the first chapter, the author presents the reader with a number of sentences that contain unneeded thats, there is’s, there are’s, etc.; the goal of the exercise is to rewrite the sentences without them. Here is my attempt. There were half a dozen vintage airplanes standing in the foreground of the museum. ... Read more

March 18, 2017

Libre de Penser

En août dernier, j’ai utilisé mon premier chèque de paie pour m’offrir un abonnement au journal Le Devoir. Ça fait maintenant 6 mois que je le lis plus-ou-moins quotidiennement (ces jours-ci, je passe plus de temps à lire sur la situation politique aux États-Unis) et c’est un 17$ par mois très bien investi selon moi: je suis mieux informé qu’avant et je peux lire sur mon téléphone, dans mon navigateur web, et même avec un lecteur PDF. ... Read more

March 11, 2017

Understanding Recursion

Recursion is my absolute favorite programming technique. It’s powerful, it’s elegant, and for many problems it yields simple and beautiful solutions. Unfortunately, recursion has a terrible reputation: new programmers find it hard and unnatural and some programmers with years of experience avoid it because of the trauma it incurred when they learned it. There are valid, practical reasons to not use recursion; fear and disdain are not good reasons. ... Read more