Hacker News new | ask | show | jobs
by skeoh 2528 days ago
> Syntax coloring isn't useless, it is childish, like training wheels or school paste

Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

7 comments

The only study I could find on the topic seems to support that syntax highlighting makes it easier to read and understand code regardless of programming experience. Calling it "training wheels" seems to be a completely useless brag, or perhaps the author has synesthesia - effectively performing the syntax highlighting in their head?

[0] http://www.ppig.org/library/paper/impact-syntax-colouring-pr...

Hugely agree. Crockford seems to assume that syntax coloring is there to be a cognitive aid for people who don't understand how to distinguish literals and operators. It's surely not, it's there to be a visual aid that lets your eye jump directly to the part of the code it's looking for.

As such the article just reads like a Chesterton's fence - "let's get rid of this thing because I don't see the use of it".

It's especially silly for someone like Crockford to say this, whose primary claim to fame is his belief that JavaScript is too hard for people to understand. "JavaScript: the Good Parts" is like training wheels or school paste.
Agreed, and it is indeed possible to have "context coloring" with normal, useful syntax highlighting alongside it - subtly lighten or darken the background color when going down a scope level into a nested function etc.
A lot of code editors and IDEs already have folding indicators and indent guide lines which provide the sort of "context coloring" that is demonstrated in the article. (VS Code's language-server based contextual folding, especially.) There are extensions to add colors to those guide lines and fold indicators, but it probably says something about how generally useful it may be in that code editors don't default to that behavior.

(For instance, in JS I've come to prefer to un-nest structures as much as possible and the provided example hit some of my code smell receptors that I would refactor it and un-nest most of it, but that's my aesthetic preference here.)

It's also a quick visual way to ensure that you and the computer agree on what the code parses as. You might think that's a keyword, but maybe a few screenfuls up you didn't escape something right and you're still in a string constant. Automatic indentation can help but... well, isn't that kind of childish, too?
I agree, but in the same way, if the code is structured well in a visual way it could be as easy to read without syntax highlighting. I guess it all depends on how well you know the language and the code base. I guess I've got into a routine for a long time now and happily have syntax highlighting turned off in Vim.
This is especially true for languages with a lot of syntactic cruft. What immediately stands out is the equal focus given to the less important characters like brackets and braces.

Still, it's a novel idea.