Live data from Hacker News

A case against syntax highlighting

linusakesson.net

11–20 of 25 posts

Re: A case against syntax highlighting

#11
post #9

There's at least two phases of developing code. There's the solving of the problem at hand, and getting the expression of that solution towards syntactically correctness. Colour syntax highlighting is merely a "live syntax checker" - albeit not as good as a compiler or linter (it's simpler in nature). But the value it adds is sufficient to make it a useful aid. It's the coding equivalent of Word's squiggly red line s…

You said “I think the only interesting point in the author's piece is the point that English text is more difficult to read when it's randomly coloured.” Åkesson didn't talk about random colors. His sample text isn't randomly colored. It's colored by part-of-speech. Nouns are red, verbs are green, etc.

I find the yellow and green parts of his sample text particularly difficult to make out, because of those color choices, not because of the changing of colors from word to word. If Åkesson wants to claim that “it will inevitably decrease the legibility of the text”, he needs to cite a study demonstrating this. As far as I know, he's just speculating.

We have a historical reason, at least, for writing prose in just one color: it is much easier to write or mass-print in one color. But now we live in an age of computers, and we could perhaps have the computer syntax-color our prose when we read (and write) it on screen and print it to a color printer. If a reader had time to get used to reading syntax-colored prose (and the color scheme were chosen well), would the reader be able to read faster or understand the material better? This question has to be answered by testing, not speculation.

Re: A case against syntax highlighting

#12
I don't think much of the case made, but this was interesting:

"Cognitively, the reading process becomes slightly less automatic and slightly more conscious; leaving less room in the conscious part of the mind for actually understanding the text."

In fact, research[0] shows that we understand and remember text better if it's harder-to-read than if it's easy.

[0] http://web.princeton.edu/sites/opplab/papers/diemand-yauman_...

Re: A case against syntax highlighting

#13

Syntax highlighting? Programmers these days rely on Intellisense, with tooltip help explaining parameters and return values as they type. Back in my day we were lucky to have an EDIT command in our BASIC interpreter. Back in the day of someone much older than me, patching binary files directly was the norm. How would programmers today even cope, should they ever be confronted with a hex editor or worse, a front-panel…

Within the last six months I used a hex editor to diagnose a problem with a PCM streaming solution and generate a "corrected" form of the output to show how my hypothesis was correct.

So I think today's programmers will do just fine.

Re: A case against syntax highlighting

#15
Natural languages have syntax highlighting; note the capitalization of proper nouns in English, or better yet all nouns in German, along with capital letters to start sentences. There are various typographical standards, all of which provide syntax highlighting, and it's arguable punctuation serves a related purpose (note the pairing of certain marks in Spanish).

after all you can still read this without it but it takes more effort i think the author may have glossed over the aspects in language because they have faded to background noise if your syntax coloring is a distraction change it if it works dont

(That was surprisingly hard.)

Re: A case against syntax highlighting

#16
Not sure I agree with this.

Syntax highlighting helps me read code very much. I notice this every time I end up in an SSH session looking at code in some version of nano without it enabled or when reading code on a webpage that is not highlighted.

Our brains are designed (or evolved) to look for patterns in things, colours help this.

Most of the time when I am in code I am not interested in reading the whole thing anyway, I just want to make a quick change to something like, for example the contents of a particular string.

In that example having the string literal inside the quotation marks light up in a different colour makes it much quicker to distinguish it from the rest of the code, the same the comments.

It also makes it much easier to distinguish where function definitions start if the definition is in bold.

Coupled with the fact that it makes it easier to spot spelling errors in keywords since they will not light up the expected colour.

I think I can also spot common patterns of code (like say foreach statements) more quickly because of the the pattern is reflected by the pattern of colours on a line.

Re: A case against syntax highlighting

#17
post #11
post #9

There's at least two phases of developing code. There's the solving of the problem at hand, and getting the expression of that solution towards syntactically correctness. Colour syntax highlighting is merely a "live syntax checker" - albeit not as good as a compiler or linter (it's simpler in nature). But the value it adds is sufficient to make it a useful aid. It's the coding equivalent of Word's squiggly red line s…

You said “I think the only interesting point in the author's piece is the point that English text is more difficult to read when it's randomly coloured.” Åkesson didn't talk about random colors. His sample text isn't randomly colored. It's colored by part-of-speech. Nouns are red, verbs are green, etc. I find the yellow and green parts of his sample text particularly difficult to make out, because of those color choi…

"If a reader had time to get used to reading syntax-colored prose..."

Ha, that's exactly what I thought when I saw that example, too.

Wouldn't written English be much easier to learn (for both children and for ESL learners) if we always wrote the different parts of speech in different pleasant/subtle colors?*

It would certainly make skimming text much easier for advanced readers - much as syntax highlighting makes skimming source code much easier for professional developers.

*(Or perhaps slightly different typefaces to get around colorblindness issues.)

Re: A case against syntax highlighting

#18
The only problem I see with relying on syntax highlighting is that it lets you manage superficial complexity and clerical details, but doesn’t address fundamental complexity. What you can get in extreme cases is heinous code that’s only tolerable to read with highlighting.

In the vast majority of cases, though, it’s helpful to ensure basic superficial correctness so that you can focus on details that actually matter. And people who program for any nontrivial amount of time develop very good attention to detail anyway.

Re: A case against syntax highlighting

#19

Natural languages have syntax highlighting; note the capitalization of proper nouns in English, or better yet all nouns in German, along with capital letters to start sentences. There are various typographical standards, all of which provide syntax highlighting, and it's arguable punctuation serves a related purpose (note the pairing of certain marks in Spanish). after all you can still read this without it but it ta…

In other words: when punctuation takes on meaning, syntax highlighting arises to fill the gap.

Re: A case against syntax highlighting

#20
post #11

Earlier quoted context omitted.

You said “I think the only interesting point in the author's piece is the point that English text is more difficult to read when it's randomly coloured.” Åkesson didn't talk about random colors. His sample text isn't randomly colored. It's colored by part-of-speech. Nouns are red, verbs are green, etc. I find the yellow and green parts of his sample text particularly difficult to make out, because of those color choi…

"If a reader had time to get used to reading syntax-colored prose..." Ha, that's exactly what I thought when I saw that example, too. Wouldn't written English be much easier to learn (for both children and for ESL learners) if we always wrote the different parts of speech in different pleasant/subtle colors?* It would certainly make skimming text much easier for advanced readers - much as syntax highlighting makes sk…

But OTOH we skim so much that we can't read anymore :)
Post reply on HN