Does Syntax Coloring Work?
Written by Ian Elliot   
Monday, 14 December 2015

Programmers divide into opposing camps: the hair-shirt-wearing one claims "I don't need no IDE" and at the other extreme the plea is "give me all the tools you can!" What you feel about syntax coloring probably depends on which group you gravitate to. Now we have some, long overdue, research that gives us some hard facts to argue about. 

Syntax coloring, or highlighting, has been around quite a while. When you first see it you either get it or think it is for baby programmers. Perhaps one of the best known public pronouncements on highlighting is Douglas Crockford's talk where he says that "syntax highlighting is for kids"

syntaxcolor1

It may be for kids, but those kids probably program better with it than without it.

A simple experiment proves that syntax highlighting is a good thing. Take two functions in Python and ask the subject to perform a modification to each, but one is syntax highlighted and the other isn't. Time how long it takes and use an eye tracker to see if there is any difference in the way the code is processed by the programmer. 

The first finding was that the tasks on the syntax highlighted code were performed faster - the difference was 8.4 seconds (the result was significant at the 0.05 level).

syntaxcolor2

In addition the programmers shifted their gaze less often on the highlighted code. That is, they performed fewer context switches. The difference was 23 context switches (the result was significant at the 0.05 level).

syntaxcolor3

So is it for kids?

Interestingly there is evidence that Crockford might be right.

There was a small negative correlation between the time difference on the two tasks and how experienced the programmer claimed to be. So there is evidence that the more experienced you are the less effect syntax coloring has on your performance.

As an aside, the author of paper notes that experienced programmers tended to underestimate their competency and less experienced programmers were more realistic. This is suggested as evidence of the Dunning-Kruger effect - but this is where the under-skilled over rate their ability. In the programming case it seems the over-skilled under rate their ability, so it is more the inverse Dunning-Kruger effect. Perhaps this is evidence that the more you learn in programming the more you realize how ill equipped you are to cope with the true nature of the task.

The amazing thing is that this study hasn't been done before and what about all the variations on syntax highlighting - why not investigate what works. It seems that we are willing to look at studies on the design of the general UI but not our own specific UI, be it IDE or code editor. 

syntaxcoloricon

The other small surprise is that the sample size was just 10 graduate students. Surely some software company could fund this sort of research and provide some strong evidence of what works?

More Information

The impact of syntax colouring on program comprehension pdf

Related Articles

Poll Results - Languages That Repay

Programming Tribes

Telegraph Contributor Says Coding Is For Exceptionally Dull Weirdos

Code By Voice Faster Than Keyboard

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin

 

Banner


Can You Solve The GCHQ Christmas Challenge 2024
20/12/2024

The GCHQ Christmas Challenge has become a pre-Christmas tradition. While it is primarily targeted at school students working in teams, GCHQ encourages both children and adults to give it a try.



GitHub Announces Free Copilot
19/12/2024

GitHub has launched GitHub Copilot Free, a free version of Copilot that provides limited access to selected features of Copilot and is automatically integrated into VS Code. The free tier is aimed at  [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 14 December 2015 )