|
|
|
|
|
by piskov
153 days ago
|
|
Why though? You don’t see a for loop? Or don’t know where is the variable and where is the method? The list goes on. Never in my life I need a color to differentiate between a class name and a variable (they already differ in first-letter case). Or between language keyword and a variable (I’m not 5, I know those keywords by heart). There is a reason we use nouns for variables, verbs for methods, stuff like isReady or hasAccess for booleans and what have you. Color is overrated (or rather very nice for stuff that matters: like comments). I like cursive though to highlight variables that are assigned more than once (bold cursive if it is a parameter, god forbid): instant attention to what is usually a code-smell. |
|
As you said, it is especially useful for making certain code smells instantly visible at a glance.
I also find that different kinds of code will get different "color rhythms" (e.g. low-level algorithmic code vs. high-level code that calls a lot of functions vs. code that does a lot of operations / mutation of object or class properties) when syntax highlighting is properly semantic. This makes scanning for certain types of things (where objects are being mutated, where variables are introduced, etc) extremely fast, since you don't even need to read the characters.
I also find that rich syntax highlighting makes the codebase easier to remember, since the color (along with things like the line-lengths) gives each function a sort of unique visual texture.
Of course, all of this is personal preference. I am a very visual thinker so this kind of stuff helps a lot for me. Some people are far more verbal in their mental imagery or may remember code chunks solely based on semantics. Then, obviously, a bunch of color and/or text decorations might not matter much, or even just be a distraction.