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


Raspberry Pi CM5 - Expensive And Undocumented
27/11/2024

So the unexpected has happened - the Compute Module 5 has been launched. But it simply emphasises some problems with adopting the Pi as an IoT device.



Prompt Engineering Techniques To Make You An Expert
18/11/2024

Introducing a GitHub repository full of hot tips and instructions on how to build the perfect prompt presented in a collection of Jupiter Notebooks.


More News

 

espbook

 

Comments




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

Last Updated ( Monday, 14 December 2015 )