Monal Gupta
Blogs

2020 · 2 min read

An ode to code golf

Writing the smallest possible program is a bad habit and an excellent teacher.

Code golf — solving a problem in the fewest characters possible — is terrible engineering practice and one of the best ways I know to actually learn a language.

To shorten a program you have to understand its semantics exactly: coercion rules, operator precedence, default behaviors, the parts of the standard library nobody reaches for.

You should not ship golfed code. But the intuition it builds — a sense for what the language will do without being told — shows up every day in code you do ship.