Why I use minimal syntax highlighting

I give a lot of attention to maintaining a high level of focus while working. After all, every person has a limited attention span. This can be lost quickly if not careful: chat notifications, email, phone, someone knocking at your shoulder. In a time when remote work is the new normal, even your pet can contribute to the distractions. And one of the goals while programming should be to improve effectiveness.

My suspicion is that one of the things that hooks some people into programming is the beauty side of it. When solving a problem in an elegant approach produces a high level of satisfaction. The burst in dopamine is something that the body will crave right after.

This feeling can be compared to what art provides to some people. However, this can have some risks. What is considered elegant can be subjective more often than not. The general consensus seems to be around code being simple, concise, and effective. It can be the outcome of fixing a task that has been bugging for a while in a few lines.

It also misses the point on where I want to put the effort and time into. Code should be maintainable, but should it please the programmer in an aesthetic way? From my point of view that should only be the case if that sense of beauty is produced by a working product. You can try to choose where you find beauty, and the source of the perception can change over time.

Some people argue online that reading code should be like reading prose, so highlighting code does not make sense. I don't agree with this as the flow in code is not linear. We have to constantly jump between locations and the number of patterns or structures are less in number and they repeat more than in standard written prose.

There has been some research regarding if syntax highlighting is beneficial for productivity. From my limited search about this topic, sadly it seems it is not conclusive. It may very well be the case that the correct way of syntax highlighting can improve productivity, but it is difficult to define what are the correct ways, which may be different for each type of person or programming language.

There can be many variations within syntax highlighting. For example, adding more or less contrast between colors. Different groups of keywords or tokens to be highlighted. There is also an interesting approach called semantic highlighting. It uses more advanced ways to extract information about the keywords meaning or context, like language servers.

Probably it also depends on the programmer's perception. Some people get more distracted than others over different bright colors. It is also important how much is someone used to a certain configuration of colors. And is relevant how often do they switch over different languages which may have slight differences over what keywords are colored.

Using color as a helping aid when skimming through code may feel comfortable for several minutes. But in my experience, when reviewing code for a long time, that aesthetic touch can lose the pleasing effect and is just given for granted. When reading code online in websites like StackOverflow or GitHub, each one will have a different theme and different groups of colors.

If one programmer has been using the same color theme for years, it can feel completely natural that a set of characters are colored in a certain way. Dark and light themes can be more beneficial depending on the surronding environment. For example, the eyes can take more rest using a dark theme when working in a dimmed room. This works as long as you are not switching to a bright window like a website over and over.

However, even if I had been using syntax highlighting since I started programming, at one point I started to develop a genuine curiosity towards if that actually helped. I tried to find serious articles advocating or discouraging using syntax highlighting. After a while, my personal conclusion was that this is just a matter of preference and not something that would make a big difference, whether choosing to use it or not.

One small idea that kept making me want to try avoiding intense syntax highlighting was: when switching between different types of files, different colors would not be in the way. I could spend more time thinking about what code means and less about why a word is in a certain color, avoiding to attach meaning unconsciously.

At first, stopping to use full syntax highlighting was not easy. It felt like I lacked something when coding without all the colors popping out. But it was surprising how quickly I got used to it, confirming that for my case there was no benefit in using overly colored code.

One important note is that I didn't remove syntax highlighting completely. Maybe I will try this in the future, but it doesn't appear as something useful at the moment, and it could even be a disservice.

There is no special theme I can recommend. I use a light theme, keeping the syntax highlighting feature enabled but turning off most of the colors. There are a few exceptions, I still enable colors for comments, strings, or diffs. There is also color in the text cursor that helps to find it in the screen quickly, and also enable highlighting matching braces.

I tend to move the rest of the UI of the text editor out of the view, with the exception of the line numbers for which I decrease the opacity or other important elements like the file name. It is also configured so I can remove those elements completely with a keyboard shortcut.

After limiting the syntax highlighting to a very few cases, I can say that I feel less fatigued when reading code for a long time. Can also focus slightly more when reasoning about a certain location in a file.

This could be just the confirmation bias kicking in, but so far I am quite satisfied with the setup and I don't intend to come back to a common color theme in the short term. I have used this approach for more than two years.

However, I wouldn't say this was a game-changer for my coding experience. I understand that other programmers are way more productive with a color-intensive theme enabled than me with this setup. I would advocate more for decluttering your editor and putting it in full-screen so you can apply laser focus when reading code.

The bottom line I would like to transmit is that if you have been coding with common colorful themes, as most editors use by default, for your entire coding life, and you have the curiosity, you can give a try to change to a minimal theme. You may be surprised if it clicks with you as it happened to me.

Back to the posts list
Loading ...