The impact of syntax colouring on program comprehension [pdf]
ppig.org
ppig.org
A more experienced colleague: "Pah, that's just a crutch". Well, yes. And?
My personal tipping point was watching a sysadmin edit resolv.conf and type "namesrever": vim picked it out in reverse red. This mistake could otherwise have gone unnoticed for a while. Good crutch.
That said, I'm completely the opposite when it comes to the command line. I think colour coding can add a lot (ls for example) but it has to be light-on-dark or not at all. Funny how that works.
It's ... meta-syntactic-highlighting for your entire desktop! Different types of windows are colored differently, just like different kinds of identifiers in one window.
I believe that the color scheme is crucially important; it's a form of ergonomics. Bad colors will lead to fatigue.
Certain choices are obviously bad, like hues that make comments or other elements almost impossible to read; insufficient contrasts and so on.
By the way, something is wrong: my Vim isn't responding to ":set background=light" (or dark). The colors change, but not the background.
I found it weird he was so deriding towards syntax highlighting.
People often think they are acting logically when frequently they are working backwards to write narratives that justify the way they choose to act.
Looking at code without coloring is like looking at a road atlas that has been photocopied in black and white.
Even some grayscale cues are better than nothing.
I actually run the Vim editor dynamically out of Apache to colorize TXR files. You can see that here and here:
http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/struct...
http://www.kylheku.com/cgit/txr/tree/tests/010/align-columns...
The second example shows a mixture of two languages: a Lisp dialect and an extraction language. Both have their own sets of standard symbols (which intersect: there are some symbols in common). They are correctly rendered in a different color: the Lisp words are green, and the extraction language words are burgundy red. This kind of thing is very helpful.
The Vim definition I maintain is quite accurate --- and not only for correct programs. I stuffed in rules so that errors are boldly flagged. For instance, even little things like using an undefined escape sequence in a character string or regex literal. (And it knows the exact set for all literals.) This works remarkably well; hardly any typos I make get by it.
Syntax highlighting definitions also help with formatting; they provide the editor with nesting cues for indentation.
Working without this stuff this day and age is completely silly.
Here was the problem:
for (int i=0;i<3;++i) {
/* Initialize important things.
frozzleTheNozzle();
}
while (1) {
/* Do ALL THE THINGS. */
makeSureTheNozzleStaysFrozzled();
}
Syntax highlighting prevents the entire class of bugs from happening (as do compiler warnings, but hey). I told one of the other guys I was working with, and he introduced me to emacs which had just gained font-lock mode.I will say though that highlighting comments and strings separately from the code doesn't necessitate full syntax highlighting. I remember (and have saved somewhere) an article on syntax highlighting where only comments were highlighted.
For example, personally I much prefer quite mild syntax highlighting — depending on the language I might distinguish things like comments, literals, and maybe some routine keywords and punctuation that could be de-emphasized. I’d also choose colours that didn’t jump out, but were distinctive enough not to confuse, say, a literal string with an identifier.
I don’t see the attraction of colouring 67 different classes of code fragment in 67 barely distinct colours myself. On the other hand, many popular editors and colour schemes do this, so it would be interesting to know whether I’m missing out on something that might be helpful.
What I do find very useful is the kinds of context-sensitive highlighting that some editors will do, for example showing matching delimiters and maybe the region between the innermost ones, or showing all references to and any visible definition of the identifier under the cursor. Subtle highlighting is still preferable to in-your-face bold colours, at least for my taste, but I find these kinds of tools do help me to navigate and understand code more efficiently.
edit: forgot to link to original post: https://lobste.rs/s/9ruzgw/screenshots_from_lobsters_users_2...
The dotfiles are linked in that post. It only really looks as pictured if you copy both the vim theme and the Xresources and use something that respects .Xresources like urxvt.
I also think emphasizing identifiers helps to see some of the structure of the code and makes it easier to notice if I misspell something.
The default --angry fruit salad-- syntax highlighting of most editors and even other people's themes are usually too much for me. This is what I use: https://raw.githubusercontent.com/aerique/emacs-theme-aeriqu...
Figure 2 shows the plain samples have much greater variance, but does that translate to significance? Some analysis here would be nice, but with n=10 you don't have enough samples for this to be significant I'd wager.
Also, the test should have thrown in a color scheme which nobody has ever used as a control. I think the choice of color scheme matters a great deal as well.
Wouln't you say that is representative of the general programmer population?
Maybe of interest is Hughes' discussion [1] of the different forms of syntax colouring. It was discussed on HN before [2].
[1] http://www.wilfred.me.uk/blog/2014/09/27/the-definitive-guid...
I do say that there's good and bad highlighting, I will tweak the highlighting colors and appearance if I can, I find many highlighting schemes are more distracting than useful. And I' sure my preferences may not meld with others.
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yesI've been wondering what is the analogue of syntax highlighting for natural languages. Still experimenting with it, but most promising is simple keyword highlighting. I've written a Chrome extension that does this:
https://chrome.google.com/webstore/detail/highlit/cooahmcpma...
Interestingly, keyword highlighting apparently helps some type of dyslexic people focus their attention on the text. With the web full of distractions, I've noticed similar effect myself. Keywords also seem to help skimming, when you're reading the text with a specific purpose in mind.
Nouns begin with a capital letter in German, and used to be in Dutch and English until a few hundred years ago. Perhaps it was because nouns are generally spoken with the greatest stress of all words in an English sentence. Perhaps such capitalization is an analogue of programming syntax highlighting.
Also marginally helpful was to delimit noun / verb phrases with 2 spaces instead of one.
Personally, I don't like that. I prefer if capitalization is a marker of names (e.g. the difference between apple and Apple).
Edit: The fact that this capitalization disappeared suggest the returns from the effort of capitalization weren't so great. But now the investment per word is much lower because the process can be automated.
So for example, 私の名前はロデリックです。The words for "I" and "name" are expressed in "complex" kanji (私、名前), connectors and grammatical stuff in hiragana (の、は、です). And my name, transliterated, in katakana (ロデリック).
I've read somewhere that, as a result, japanese is painful to write, but a pleasure to read. I'm not there yet but I can sort of see it.
I've been wondering what is the analogue of syntax highlighting for natural languages.
Typography.Well, we have bold and italics to emphasize important parts of a phrase (and underline, which is often used in handwriting for that purpose).
Since we don't work with different colors when reading/writing, we also use things such as punctuation, e.g. ? to denote that a statement is a question, ! that it intends to show wonder, etc.
I've done this since highschool, because a full page with single coloured text seems incredibly boring to me, and it draws my attention away.
But it still sounds worse than it actually is, I promise it's a lot clearer than it sounds. Most of this is technical stuff with formulas or code, so it helps a lot more than it seems from the description. And the "full 8 colours" are only used in special cases with a lot going around.
The Writer Pro app from iA has a "Syntax Control" feature: https://brooksreview.net/2014/02/does-syntax-highlighting-ac...
https://camo.githubusercontent.com/6fb786753708404177aaa0a2f...
In daily life I use a very colorful scheme (darcula on steroids) and just thinking about monochrome makes my head hurt.
Another article from the opposition, which I partly agree with: http://www.linusakesson.net/programming/syntaxhighlighting/
(Linus Akesson is what I'd consider a highly experienced programmer, and the rest of his site is worth looking at for lots of other interesting stuff.)
It's nice to see that the comments section is still going strong, 8 years later.
This just makes me wish you could get syntax-highlighted prose. It's not necessary for languages you have a native understanding of, but think how helpful it would be for foreign languages. :/
I'm not questioning he's a very experienced programmer, but I know this type of highly skilled programmers - they're awesome working on solo projects and you'll be amazed at their nuclear alarm clock with Klingon language recognition, but working with them as a team tends to be an ordeal. I'm >80% sure I'd have to put the guy in this category had I met him.
I tried having no syntax highlighting for a few months, and it was usable, but not as good as with syntax highlighting.
A lot of the problems I have with Vim and syntax highlighting is using VT100 or badly configured graphics systems. Personal taste, one style I do use is the old Borland colours which came out with Turbo Pascal. Works on all the monitors I've got ~ http://www.vim.org/scripts/script.php?script_id=92
That's why some schemes work better than others: what you want to find quickly is key structural signals in the code. If you highlight comments strongly, say, it'll miss the point (unless your proof reading comments of course).
So, to your question, the value will depend on whether or not there are structural cues that it'd help sufficiently to highlight.
Interestingly we do do that to some extent already. For example, indenting and capitalising the start of sentences, indenting (and spacing) paragraphs, italics and bolding for emphasis. That sort of thing.
So using highlighting in the places we currently do could well improve what we already have. For example, colouring the first word in a paragraph or increasing the font of the sentence capital.
What would be fascinating to study would be if we could use it to help with word or sentence stress. I could imagine that, done carefully, this could help with learning languages.
Even though it’s not really worth noting due to the first issue, the right example also seems to require more focuses (87 over 65)?
https://groups.google.com/d/msg/golang-nuts/hJHCAaiL0so/kG3B...
"Thus, if a participant completed the plain version of a task in 60s, and the highlighted counterpart in 30s, the time advantage for that task is 60s/30s = 2"
The part of the range below 0 corresponds to time advantages < 1, i.e. it took longer for the highlighted part than the plain one. Several times longer, if the results are to be believed (there's one around -0.7 and three at -0.5; that's a "time advantage" of approximately 0.2 and 0.3, or 5x to 3x slower.)
http://www.youtube.com/watch?feature=player_embedded&v=dkZFt...
Crockford is always right.