Reasonable Performance

Less intrusive color theme

April 17, 2017

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?) When every syntactic construct is highlighted, none of them jumps out, and doesn’t that defeat the purpose?

Take a look at the screenshot of Sublime Text below; I find it difficult to focus on anything, too much is highlighted.

Sublime Text

Some programmers have written about turning off syntax highlighting entirely, but this is too extreme for me. In the TeXBook (p.13), Don Knuth gives this advice to the reader about special typefaces:

Special fonts are effective for emphasis, but not for sustained reading; your eyes would tire if long portions of this manual were entirely set in a bold or slanted or italic face. Therefore roman type accounts for the bulk of most typeset material.

Too many colors—as is common in programming text editors—is not ideal, but neither is a competely barren buffer. A book that exclusively used Times New Roman 10pt would be extremely difficult to read. Moderation is key.

I tried many Emacs themes over the years, and we are lucky to have a large collection of well-designed themes. If you don’t mind a lot of colors, the material themes are quite nice.

However, since I couldn’t find one that used only a few colors, I decided to build my own, Purp. It’s not too hard to do in Emacs, and there are plenty of open-source themes that one can use for inspiration and education. In Purp, I tried to minimize the number of colors and the number of elements that are highlighted. You can see the result in the screenshots below.

Purp Theme
Purp Theme

I consider that the following elements are important enough to have their own color:

Everything else uses the default typeface. I think the code looks much “calmer” than it did in the Sublime screenshot.

Purp isn’t publicly available yet, because there’s still a lot of work left to do. My installation of Emacs defines 418 faces (org mode has 75), but I’ve only defined colors for 25 of those.