Kebab Case and Infix Notation
2023-1-8

Of all the conventions for naming things in programming languages, kebab-case is the most pleasing. It's better than camelCase and snake_case and everythingruntogether. The only problem is that we want to use - as an infix operator for subtraction.

One fix is to require spaces around - operators to disambiguate them from parts of identifiers. I mostly put spaces around operators anyway, since it's easier to read.

A minus sign is a very consequential thing in a program. In programs for controlling robots, negating a expression typically reverses its effect. But the - character is visually very small. NASA supposedly lost a rocket due to a spurious - in the code. (I'd fact-check this, but I fear I'd lose an afternoon down that rabbit hole.)

So rather than change the syntax of my language, I changed the rendering. An - character (subtraction) renders as a big fat em-dash, and a _ character (part of an identifier) renders as a small en-dash, making identifiers look even better than regular kebab-case. Here's a screen shot, showing how visually prominent the negations are:

Thanks to Hillel Wayne for the inspiration [HN discussion].