Humane Code Highlighting and js2-mode
One feature of many text editors that I’ve always been a little skeptical about from a user interface perspective has been syntax highlighting. It certainly looks pretty and serves to make the process of reading and writing code more satisfying, but I’ve had a hard time justifying to myself that it’s something that’s truly useful in a concrete way.
The few examples that always come to mind are when syntax highlighting alerts me to the fact that I’m using the wrong syntax. For instance, a few days ago I was writing CSS that looked like this:
It struck me as odd that the term font-decoration was black, unlike the green terms above it. Without having to read any instructions, it was easy to infer that perhaps I font-decoration wasn’t a valid CSS property. When I tried text-decoration, the term lit up green, indicating that I was on the right track. This was far more pleasant and less cognitively jarring than saving the file, switching to my browser, reloading the page, and discovering that my page didn’t look like what I wanted.
For instance, take this example:
Here js2-mode has underlined the variable poke in orange, which is its indicator that what I’ve typed there, while it will certainly compile and run, may not be the best idea. Moving the cursor to the underline, the text Variable poke hides argument appears in the minibuffer, alerting me to the fact that I won’t be able to access the poke parameter to my function because I’m redefining it in the body of the function.