Why Good Syntax Highlighting is Important

Ashish Bailkeri - Oct 17 '21 - - Dev Community

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.

. . . . . .
Terabox Video Player