Hacker News new | past | comments | ask | show | jobs | submit login

I suppose that these days I am one of the few professional programmers who has an active dislike of syntax highlighting. I find it immensely distracting. The only stuff I allow the highlighter to touch are my comments (I turn them bold) and I consider this a somewhat frivolous indulgence.

(I appreciate the complexity of the problem, btw)




To each their own, and fortunately most(all?) editors allow such features to be turned off.

On the other hand, I find the "frivolous indulgence" perspective extremely obnoxious along with the related implication of moral or technical superiority of not using syntax highlighting.

As a side note, the way it helps many people who prefer it has some fascinating cog-psych underpinnings: https://en.wikipedia.org/wiki/Visual_search

Sometimes I wonder if those who don't prefer it might have some synesthesia which might allow their brain hardware to provide what the syntax highlighting does for the rest of us.


Yes it's pure egotism. "I don't need silly colours to code, not like those noobs."

You get the same attitude a lot for things like autocomplete and even for static typing.


I guess it turns out actively depriving yourself of relevant information at a glance isn’t that popular, no.


While I'm aware that OP and I are in a minority - there is a cognitive overhead to having that information surfaced at all times when you may be trying to focus on something at e.g. the method level rather than the individual syntactic element level, and if that cognitive overhead exceeds the utility of having that information available, the sensible answer is to turn the highlighting off.

If I could have some sort of focus follows mind where highlighting automatically happens commensurate to what level of granularity I'm currently thinking about the code at I would be extremely interested, but absent "focus follows mind" it's a trade-off that everybody has to make for themselves.

Some people prefer to highlight almost everything, some almost nothing, some people find it helpful for some languages/tasks but not for others.

It's similar IME to the extent to which preferred debugging styles (printf versus interactive versus hybrid versus situational choices) are also something people have to figure out, and, well, different people are different, and that's neither a bad thing nor an avoidable thing.


I wonder if perhaps this is also a generational thing. Programmers from before syntax highlighting became popular would be less likely to prefer it, no? I’m not even sure if programmers from current/recent generations ever prefer not to have syntax highlighting, but I’m genuinely curious if there are such people out there.


I've known people who've started without synhi but wouldn't leave home without and people who started with rich synhi everywhere and now avoid it except for the first couple months of learning a new language, so it's certainly not just generational.

I would not at all be surprised if people who started off one way or the other (for generational reasons or indeed any 'whatever environment they were first introduced to' style reasons) are less likely to end up switching, but that probably says more about perceived switching costs as what would be most comfortable for somebody.

e.g. I know people who took a month to be comfortable without synhi but then loved that, and I've spent weeks trying to be more comfortable -with- and given up, and honestly anything that half screws your productivity for over a week is going to be a hard sell even if the end result -would- be better (waves in "also, still can't manage to drive emacs" ;)


I grew up with fully fledged syntax highlighting, but I still prefer to use really minimal themes as I find them to reduce cognitive overhead and eye strain.

It was hard for the first few hours, but then I eventually got used to it, and now I can't use anything else.

I know this is not quite as extreme as working without syntax highlighting :)


I started before syntax highlighting became widely used (in the Emacs 18 era), but was super-excited for syntax highlighting when it became available (Emacs 19 and XEmacs), and probably went overboard with it. These days, I prefer minimal syntax highlighting.


Not sure which editor I'm thinking about, but I do remember the exact feature you're describing implemented in one I used a while ago.

Ie, the paragraph (or block of code) your cursor is focused on is visible, the rest of the code is blurred out.


I recall that as well, my guess would be Sublime Text. Ah, it might have been this plugin for Atom, I was using that for a while:

https://github.com/davidleghorn/atom-focus-mode

Edited to add that I found this for VS Code which I might try:

https://marketplace.visualstudio.com/items?itemName=imagio.v...


I think I met this feature specifically in an editor made specifically for markdown and markdown only.

Although I can definitely imagine this being a plugin in different editors


The IDE could temporarily turn off all syntax highlighting outside the node that has the cursor.


Where the cursor is and where my mental focus is don't necessarily match, and it's really the granularity problem - expression level versus statement versus block versus etc. that causes 'mismatch between highlighting and focus' for me at least.

It certainly sounds like an experiment that would be interesting to try, though.


The way I see it, most syntax highlighting is actively adding mostly irrelevant information to the cognitive load of programming: stuff that should be obvious if you know the language. It does as little for my understanding as a novel in which, say, every proper noun was printed in red.

I can imagine more useful highlighting than color coding the types of the symbols encountered. Lighting up the active scopes. Giving the same hue to names that look like each other. There are probably highlighters out there that do that. But "simple" syntax highlighting is still the norm.


The same argument could be made for seeing anything in colour:

> most colours are actively adding irrelevant information to the cognitive load of existing. It should be obvious that apples and red and the sky is blue.

That’s silly, because it does add relevant information. Obviously it’s a spectrum - too many colours can hide information, but when used appropriately it’s fine.

Also everyone is different. Perhaps your brain gets distracted by the colours more than the majority of people.


> Lighting up the active scopes

As you had guessed a little later, there are a few different emacs packages that do this. One of them is "rainbow parentheses" that gives every bracket a different colour (remember that emacs supports lisp, so differentiating between lots of different parentheses is arguably more useful in emacs than any other editor). [0].

Another one is highlight parentheses [1] which highlights all parens that enclose the cursor position, and gives a darker colour to those "further away" from the cursor.

[0] https://github.com/Fanael/rainbow-delimiters

[1] https://sr.ht/~tsdh/highlight-parentheses.el/


> Giving the same hue to names that look like each other.

Emacs' 'Rainbow Identifiers' does that. I like it.

    https://github.com/Fanael/rainbow-identifiers


Define relevant


While I don't fully disable syntax highlighting, I use a minimal theme [0,1] that only has highlighting for comments, strings and globals. It reduces eye strain for me, and I never find myself relying on highlighting to navigate through code.

LSPs provide an "outline" which can be very useful to navigate through code. I find "jump to symbol" function in my text editor to be faster than scanning all of the code to find the line.

Also most themes dim the comments, but IMO if something in the code needed an explanation, it should be brighter, not dimmer.

[0]: https://github.com/tonsky/sublime-scheme-alabaster

[1]: https://github.com/gargakshit/vscode-theme-alabaster-dark


> Also most themes dim the comments, but IMO if something in the code needed an explanation, it should be brighter, not dimmer.

That makes me crazy! I use base2tone, which is not nearly as minimal as your theme but more than most, and I modify the comments to be bright.


Syntax highlighting is pretty redundant. Some interesting alternative uses of colour information are given at https://buttondown.email/hillelwayne/archive/syntax-highligh... (e.g. colouring different scopes, or different imports)

I also like the idea of using colour to distinguish different identifiers, e.g. https://wordsandbuttons.online/lexical_differential_highligh...

https://medium.com/@evnbr/coding-in-color-3a6db2743a1e

https://zwabel.wordpress.com/2009/01/08/c-ide-evolution-from...


A few years ago I switched my color theme to something very simple, just as an experiment.

Somehow I never found a need to change that. I highlight comments, keywords, and strings. Comment and string highlights are helpful if they contain code-like text, to make them obviously not-code. Keywords give some structure to the text.

Everything else is frivolous to me. Books do not highlight verbs in green, either.


> Books do not highlight verbs in green, either.

While I will not argue with your general point -- I also don't really need highlighting and I read a lot of plaintext code -- I wonder about this.

Would this make languages easier for non-native speakers? Would improve comprehension?

It's funny that the industry spends so much time on syntax highlighting for programming languages, when humanity's written languages are arguably more complex and difficult to parse and master.


> Would this make languages easier for non-native speakers? Would improve comprehension?

When I've been trying to learn languages, I can typically part-of-speech tag unknown words quite easily (common prefixes/suffixes/word length/sentence position give lots of information – and some of this is shared across languages as well). The comprehension difficulty is nearly always due to content words I haven't seen before (or have forgotten).


I think the point is that books do highlight things: Headlines, italics, Capitalization. Just not silly technicalities like parts of speech.


Not to bikeshed on this, but I have a pretty strong preference for minimalist syntax highlighting. I'm currently using tao-themes in emacs: matching light and dark themes that are grayscale or sepiatoned, and mostly use character properties like bold or italic along with a few shades of gray. Much more calming than the usual "angry fruit salad on black" programmer themes, but also providing more intuitive information than no syntax highlighting.


Thanks for the recommendation! I've been on the lookout for a good monochrome theme, this looks great to me w/ boxes off


I feel the same way. Never understood what the point of highlighting certain keywords or if something is a type or a function would be, it's all obvious from the grammar and where things are positioned anyway. And When I read code I want to read all of it, not draw any particular attention to "if" or "else".


Keyword highlighting is explicitly called out as an antipattern in the book Human Factors and Typography for More Readable Programs, which I highly recommend.


I would normally respond that, as others have pointed out, you're basically saying you prefer to "hide" information that, to most people, is relevant (is this a keyword, a global or local variable, a type, a method, a static function...), but I've noticed that when I'm doing code review, using the shitty BitBucket interface which shows everything red or green, without any code highlighting, actually helps me a little bit to focus on the changeset as opposed to what the code is actually doing in general. This is helpful because the changeset is what I care about when doing a review (what's different than before is the first question, with understanding what code is actually doing comes second)... Later, I might need to look at the code in my IDE with proper highlighting to better understand what the changed code is actually doing in more detail, but that's rarely needed (unless it's comprehensive changes).

So, it occurred to me that whether syntax highlighting is actually useful depends somewhat on the context, what are you trying to do?!

I suppose it's easy to extend that realization to people who are different and might feel overloaded by information more easily, so I can sympathize with what you're saying (hope this doesn't sound condescending, I am just trying to say people can have very different cognition overload levels, regardless of how capable they actually are in general).


Anyone interested in syntax highlighting should read the book Human Factors and Typography for More Readable Programs. The majority of the book is devoted to non-color techniques, but they do present some ideas for how to effectively use color near the end.

Much of syntax highlighting in the wild is junk, just distracting eye candy.


how do you know when you have missed one single parenthesis somewhere ?


I am very fond of things akin to vim's 'showmatch' mode where when I close a paren or block or etc. the editor highlights the opening element for a second or so and then returns to baseline.

(I have almost no -ambient- highlighting in my baseline but I know lots of people who do and still derive great value from showmatch for the feedback - from discussions with other people rainbow parens style lisp modes seem to provide a maximum overkill approach to that question but I very much prefer maximum underkill in my own tooling even while wanting to be very sure I'm not making it unduly difficult for collaborators with opposite preferences)


Emacs blink-matching-paren minor mode does this. It’s quite configurable, like every other thing in Emacs.

Some of the alternatives can be found by starting at: https://www.gnu.org/software/emacs/manual/html_node/emacs/Ma...


Does it sound presumptuous if I say that hardly ever happens? And if it does, the compiler never fails to remind me. :-)


There's no correct answer here, it's totally subjective.

I can sympathise with both sides; I like syntax highlighting when it's done well - when it's distracting I turn it off.

Seeing a keyword highlighted within a comment is an instant red flag - unfortunately it happens loads in Azure Data Studio (which I need to occasionally use).

Never happened in TreeSitter though.


parentheses matching is a surprisingly non-trivial problem. (i.e. simple counting of opening and closing parens isn't sufficient, given that quoted parens shouldn't be counted) For humans, ignoring quoted parens is maybe easier, but i would say it's a flex to assert that you can tell if (3,(g(f('('),x))) is balanced at a glance.

even if you can, surely you're wasting time and/or focus on an automatable task.

But we all have something we do 'the hard way' because it feels like more effort to relearn the task than its worth, or because we tried the easy way once and were put off by some side-effect.

paren highlighting never comes as a single unit, its always packaged with other 'helpful' tools, some subset of which will always be infuriating to someone.


> For humans, ignoring quoted parens is maybe easier, but i would say it's a flex to assert that you can tell if (3,(g(f('('),x))) is balanced at a glance.

True, but mentally balancing parentheses is usually something that you do while writing the code: you pushpop a little stack in your head and this becomes second nature.

Mentally verifying if parentheses are balanced while reading code is hardly ever required. You can usually safely assume that they are (unless that darn compiler tells you otherwise).


you're probably right, difficulties when writing are mainly due to tools 'helpfully' adding a ket as soon as i type a bra.

maybe i just dont have that stack well enough built in my head--if im editing in a plugin-free vim, i do find i have to backtrack and count to make sure i've put the right number of kets at the end of a nested expression.

if i used s-expressiony instead of tab-heavy languages more often i'm sure i'd be better at it.


Not the OP, but my editor colors the parenthesis red in case of an imbalance [0].

I do have a minimal amount of highlighting though.

[0]: https://imgur.com/haVWset




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: