DEV Community

Cover image for Why Good Syntax Highlighting is Important
Ashish Bailkeri
Ashish Bailkeri

Posted on • Updated on

Why Good Syntax Highlighting is Important

All code snippets posted are under the MIT License

So does it really matter?

Yes. There good programming practices in certain programming languages but there is also good developing practices and this is one of them.

So what are the advantages?

  • Higher Productivity
    • When programming with better syntax highlighting it becomes easier to identify where parts of your program is based on the color. With color schemes with limiting syntax highlighting on certain semantics, it can be really difficult to differentiate between what may be a parameter variable or a local variable, or in the case of C++, macros, enum values, global variables, etc.
  • Encourages you to code
    • What do I mean by this? I mean that you actually feel more engaged looking at a theme bested suited to your programming style, for me, I prefer a diverse array of colors on my screen.

Let me show you what I mean:

Colorful Example:
Good Syntax Highlighting Example

Snippet from Jet.

What does this do well? It has a vast amount of colors that is easy to differentiate parts of the program immediately, it is not just about I have highlighting, but it really tries and brings out different parts of the program. I can easily point out macros, class variables, parameters, and functions almost instantly through this highlighting.
But for some, this might be overkill in colors, and you may prefer a softer tone.

Note: This is my opinion of course, but in general you should choose a theme that suits your programming style the best

Of course, this also depends on your editor's capability but other popular editors like Visual Studio Code, still provide support for semantic highlighting. But we can see clearly how this highlighting can improve the coder's experience and provides clarity.

Another Interesting Example:
Okay Syntax Highlighting Example
This theme is known as Darcula, JetBrains's default dark theme syntax highlighting, and while it does the job, is less colorful. Important type values such as size_t don't have clear highlighting in this example and can easily be overlooked as they have a very similar color to the delimiter tokens. This is not say it isn't a good theme, it is, and is far better than editors with only keyword highlights. What does it do well? It has a far softer theme than the previous example, and still manages to highlight important parts of the program.

In general, good syntax highlighting themes needs to be able to have ways of identifying important parts of the program, and JetBrains's IDE's usually give the programmer enough flexibility to adjust their highlighting.

Disadvantages of Good Syntax Highlighting

  • Get lost in the sea of colors that is your code
    • No? That's just me? Well let's move on then.

Conclusion

My opinion is this: the making of a good programmer is one that knows how to use the tools available today to further increase their skills, and this includes something as subtle as syntax highlighting and font choice. You don't have to stick with something like my syntax highlighting, rather you should find the one best suitable for you.

Top comments (12)

Collapse
 
thedenisnikulin profile image
Denis

Personally, I find color schemes with such colors as in the first example quite toxic and unpleasant to my eyes. It's quite subjective, but I would prefer JetBrains' Darcula theme because of aesthetic and softness, and I don't experience any issues with distinguishing syntax elements, it feels okay!

Collapse
 
aboss123 profile image
Ashish Bailkeri

That's perfectly fine. Personally I like the first one because I can match the syntax with the property faster, it really is personal preference, but picking syntax highlighting that is suited to your programming is always more efficient.

Collapse
 
satrun77 profile image
Mohamed Alsharaf

Everyone have their own preferences and that is ok🙂

Personally I like Phpstorm with dark material theme UI, Friday Mario, and Power mode 2 😅

plugins.jetbrains.com/plugin/8006-...
plugins.jetbrains.com/plugin/7599-...
plugins.jetbrains.com/plugin/8251-...

Collapse
 
aboss123 profile image
Ashish Bailkeri

Interesting themes! Yep, I agree that syntax highlighting is subjective, and you should definitely pick one that you prefer over anything else like it says in the article.

Collapse
 
hiteshx123 profile image
Hitesh Ale • Edited

Ofc its important even textpad++ got it.

Collapse
 
manoj_shukla_10 profile image
Manoj Shukla

Higihlighting syntax helps to make code easy to understand & improve its readiblity.

Collapse
 
lestrae profile image
Alex

What theme on first screen?

Collapse
 
aboss123 profile image
Ashish Bailkeri

It's called RainbowDrops, rather a modified version of it. It's based on the original Eclipse Dark Theme.

Collapse
 
lestrae profile image
Alex

ty!

Collapse
 
pavelloz profile image
Paweł Kowalski

I would also say that font legibility is also very important. Its a pleasure to work with a good font + nicely colored code. :)

Collapse
 
aboss123 profile image
Ashish Bailkeri

I agree! I totally recommend Iosevka, it's pretty good.

Collapse
 
twolfvb profile image
Tomás Wolf • Edited

Just created this account to give a shout-out to GapStyle the best semantic highlighting I've seen.
Please give it a try, I use it in CLion and in vscode