Live data from Hacker News

Context Coloring

crockford.com

1–10 of 21 posts

Re: Context Coloring

#2
> Syntax coloring isn't useless, it is childish, like training wheels or school paste

Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

Re: Context Coloring

#3
post #2

> Syntax coloring isn't useless, it is childish, like training wheels or school paste Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

Agreed, and it is indeed possible to have "context coloring" with normal, useful syntax highlighting alongside it - subtly lighten or darken the background color when going down a scope level into a nested function etc.

Re: Context Coloring

#5

What about context coloring the background color and syntax coloring the code? Which maps well conceptually as well.

Another idea... what about the IDE inserting a subscript or superscript after a variable to indicate how many contexts removed from the current context it was defined? Or possibly to indicate type information.

Re: Context Coloring

#6
It's so long since I've written any code without syntax colouring, I don't even know if it can be turned off in my main GUI tools (IntelliJ & VS Code). When I've occasionally seen code in notepad or an unconfigured vi, it looks like an undifferentiated mess. Which isn't to say it wouldn't be a useful or interesting exercise to try without it for a while. What we're habituated to isn't always a good guide for how to proceed.

Colouring by nesting level might be useful in javascript, but strikes me as a poor idea in the other languages I'm using right now (Java, Go, Rust). Nesting is often accidental complexity, and can usually be reduced with a bit of thought. For that reason I'm happy for deep nesting to be visually confusing - it's a useful extra motivator.

(Come to think of it, with async/await, one of the main cause sof deep nesting in javascript can be minimised also).

Re: Context Coloring

#7
post #2

> Syntax coloring isn't useless, it is childish, like training wheels or school paste Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

This is especially true for languages with a lot of syntactic cruft. What immediately stands out is the equal focus given to the less important characters like brackets and braces.

Still, it's a novel idea.

Re: Context Coloring

#8
post #2

> Syntax coloring isn't useless, it is childish, like training wheels or school paste Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

Hugely agree. Crockford seems to assume that syntax coloring is there to be a cognitive aid for people who don't understand how to distinguish literals and operators. It's surely not, it's there to be a visual aid that lets your eye jump directly to the part of the code it's looking for.

As such the article just reads like a Chesterton's fence - "let's get rid of this thing because I don't see the use of it".

Re: Context Coloring

#9
post #2

> Syntax coloring isn't useless, it is childish, like training wheels or school paste Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn't mean it's useless, or only for programmers who need training wheels. It makes scanning code by eye so much easier, in the way that capital letters make reading this blog post easier.

The only study I could find on the topic seems to support that syntax highlighting makes it easier to read and understand code regardless of programming experience. Calling it "training wheels" seems to be a completely useless brag, or perhaps the author has synesthesia - effectively performing the syntax highlighting in their head?

[0] http://www.ppig.org/library/paper/impact-syntax-colouring-pr...

Re: Context Coloring

#10
> Syntax coloring isn't useless, it is childish, like training wheels or school paste

Not as childish as writing a blog post bragging about how you don't need syntax highlighting to code.

In all seriousness, though: yes, after a while, you don't usually need it. But it's an immediate visual confirmation that I used the wrong type of quote for a string literal, or that I forgot my `def` statement before a python function. Unless you literally never make these errors (or the myriad other little errors that can be caught this way), syntax-aware editor tools like syntax highlighting or auto-indent will save you time by alerting you of your error promptly and letting you fix it without getting distracted. Nothing beats having the whole page suddenly look the wrong color to get your attention.

I actually can't think of a better way to avoid the class of errors that highlighting instantly exposes.

[edit] I do agree with Crockford that extra types of highlighting/formatting for readability can be great, including context-based coloring; emacs's rainbow parens does something similar based on enclosing parentheses, though the interior of the parentheses is still highlighted in the standard way.

Post reply on HN