Live data from Hacker News

Syntax Highlighting Off

robertmelton.com

51–60 of 110 posts

Re: Syntax Highlighting Off

#51
Syntax highlighting is a topic where EVERYONE has an opinion, so I'll give my 2 cents as well. I am using solarized light (http://ethanschoonover.com/solarized) for my coding, and am very happy with it. I like having keywords emphasised, because they convey a lot of the structure of the program. If you need to switch syntax highlighting off to see whether code is ugly or not, you might not have a very refined sense of beauty anyway. That said, I am perfectly fine with programming without syntax highlighting, I am not dependent on it to understand code. It is similar for type inference: I think it is OK if it makes your code easier to read, if you use type inference though to a point where you cannot understand / write your code without it, you are doing it wrong.

Re: Syntax Highlighting Off

#52
post #45
post #34

Earlier quoted context omitted.

> I don't understand the reasoning behind this. What possible benefit could you get from turning off all syntax highlighting? He explained his reasoning (and theories why it would work) in enough detail. You might disagree, but I can't see how you can't understand it. > It's useful to distinguish between language keywords and user specified names. Being able to visually ignore one of them, while focusing on the other…

Yes, I read his reasoning, but I still can't make sense of it. The most common theme seems to be that having more colors is "distracting". I mean yes, having more colors gives your eyes more things to process... the same way that 7 letter variable names creates more work for your eyes compared to 2 letter variable names. But if someone told me that they avoid naming their variables using complete words because it's t…

I found the Alice in Wonderland image at http://www.linusakesson.net/programming/syntaxhighlighting/ particularly compelling, in support of the argument that highlighting may emphasize syntax at the cost of obscuring semantics.

Re: Syntax Highlighting Off

#53
post #49

Purely eye candy here--visual enjoyment that makes code seem more interesting and fun. Did anybody else go from needing a white background, to preferring a dark one? (I had the zebra effect for years when trying to read light-on-dark, then one year something changed--I don't know exactly what.)

Yes, I switched to dark background mode a few years back and it's made a huge difference in my coding productivity and eye strain. There's one IDE I use occasionally that sadly has no ability to theme (PowerGUI for PowerShell) and you're stuck with a white background...and zebra effects after an hour or two using it.

Re: Syntax Highlighting Off

#54
I think the usefulness of syntax highlighting is highly dependent on the amount of colors you use. For me, anything more than three separate colors is just visually distracting.

It's also nice to have low opacity comments, as many others have said.

Oh, and never bright colors. I use solarized or similar.

Re: Syntax Highlighting Off

#55
post #18

Syntax highlighting can help structuring your source code when done well and tastefully - coloring your source in all bright colors of the rainbow rather achieves the opposite effect. Personally I am working with a white background, so I try to keep the syntax colors all very dark, so while the different colors can be seen, they should not distract from reading. The correct amount of highlighting very much depends fr…

One of my criteria for choosing a theme for source highlighting is that it not make keywords both bright and bold at the same time, which makes code harder to read and to scan. A startling number of themes do this.

Judicious, typographically aware use of bold and italic or oblique in source highlighting can be a wonderful thing.

Re: Syntax Highlighting Off

#56
post #24

I'd freely speculate that 90% of the benefit of syntax highlighting comes from mere lexical highlighting - specifically, making comments, strings and keywords visually distinct from everything else. And even keyword highlighting is very secondary to the first two. Making comments distinct from normal code is nice because you can easily alternate your focus on one or the other while reading through; and you're not lik…

One of the most important benefits of syntax highlighting that no one in this thread seems to be discussing is the highlighting of syntax errors. That is the number one benefit of syntax highlighting for me. It immediately shows me where there's a problem in my code (like if I haven't closed parenthesis or quotes) and keeps me focused on "completing the thought", as it were. This is also a reason that I don't like us…

The author does mention that, though, when he's talking about the pros and cons in the very beginning of the article:

> What do I miss? Syntax highlighting hinting that I made a dumb typo (importance is directly proportional to compile time or speed of running syntastic).

Re: Syntax Highlighting Off

#57
In hindsight, while comments and strings deserve syntax highlighting there's an argument that the rest is a solution looking for a problem. I'd argue that the highlighting would be better-spent giving each nested tier of parens a distinct color. Like make the first tier brown, then do ROY G BIV, and if you need more than 8 tiers I don't want to read your code.

Re: Syntax Highlighting Off

#58
post #45

Earlier quoted context omitted.

Yes, I read his reasoning, but I still can't make sense of it. The most common theme seems to be that having more colors is "distracting". I mean yes, having more colors gives your eyes more things to process... the same way that 7 letter variable names creates more work for your eyes compared to 2 letter variable names. But if someone told me that they avoid naming their variables using complete words because it's t…

I found the Alice in Wonderland image at http://www.linusakesson.net/programming/syntaxhighlighting/ particularly compelling, in support of the argument that highlighting may emphasize syntax at the cost of obscuring semantics.

I've not found that Alice analogy colorizing the "verbs" convincing.

With human language like English, we learn it and use it without the formal grammar++. A 5-year old child can speak to her mother ("I want some candy!") without conscious knowledge of "verbs" or "nouns". A formal grammar for categorization is what we layer on top of language for analysis in school. Two people can communicate and understand each other without any exposure to any grammar lessons. So yes, colorizing verbs looks superfluous and noisy.[2]

On the other hand, computer programming syntax starts with grammar. You learn that certain specific tokens are "data types" and other tokens are "literals", etc, etc. And that grammar categorization in programming languages never goes away as you're typing out new code. (Otherwise, you'd get a compiler error or unintended behavior because x="3"+"5" with quotes ("35") means something different from x=3+5 without quotes (8).) This is why so many programmers find color highlighting helpful even if they've been programming that language for 10+ years. Sure we want to focus on higher cognitive purpose of "semantics" but the grammar is deeply intertwined with reconstructing what the semantics is.

A closer analogy of color highlighting in a different realm would be different colors in TCPIP traces such as "red" highlighting external ip addresses. This can be helpful for forensics of malware phoning home.

Or in financials dashboards where uptrends are "green" and downtrends are "red".

The same reasons that colors help the malware analyst or stock trader quickly parse data at a glance is also how it helps programmers.

++ (at least not consciously that a 5-year old would be self-aware of it. A theory of innate universal grammar in the brain by Chomsky isn't what I'm talking about.)

[2] except for rare examples of using annotation or coloring of verbs to help parse sentences like this: https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal...

Re: Syntax Highlighting Off

#59
post #22
post #18

Syntax highlighting can help structuring your source code when done well and tastefully - coloring your source in all bright colors of the rainbow rather achieves the opposite effect. Personally I am working with a white background, so I try to keep the syntax colors all very dark, so while the different colors can be seen, they should not distract from reading. The correct amount of highlighting very much depends fr…

> coloring your source in all bright colors of the rainbow rather achieves [badness] Low-hanging fruit is the braindead R/G/B/Cyan/Magenta/Yellow used by some terminals in response to ANSI escape codes: https://sdkmvx.files.wordpress.com/2008/08/ansi-colors.png In my mind, there's three types of colouring: None, Designed-By-Human, and the aforementioned Eye-Searing-255 (which should really be killed off or at least n…

> Eye-Searing-255

Lol....this. If your primary workstation OS is Windows then I recommend grabbing a copy of MobaXTerm. It has the ability to override and tame the "Eye-Searing-255" beast with its own themes (Solarized Dark and Light, Pastels etc). No more "oh-my-god-my-eyes" when you open up "ooby-doofer.pl" in vim.

Re: Syntax Highlighting Off

#60
post #32

This post misses, for me, the greatest benefit of programming without syntax highlighting enabled. I went through a period of doing it for 5 years or so and the biggest effect was ultimately on how I wrote code, not how I read it. Without syntax highlighting I gradually became more focused on the legibility of what I was writing, because none of the visual cues were there when I read stuff back. Function length, modu…

That's an interesting point. However, this will only work when you're only ever reading your own source code. In Ruby code, I've seen a lot of very long expressions formatted without any spaces at all, like: (artifical example)

  @posts = Post.where(author:params[:author_id].to_i).map{|p|p.comment_count}.select{|c|c>5&&c
I often found myself properly formatting the code before I could even read it.
Post reply on HN