TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Context Coloring

21 pointsby thisisblurryalmost 6 years ago

8 comments

stefco_almost 6 years ago
&gt; Syntax coloring isn&#x27;t useless, it is childish, like training wheels or school paste<p>Not as childish as writing a blog post bragging about how you don&#x27;t need syntax highlighting to code.<p>In all seriousness, though: yes, after a while, you don&#x27;t usually <i>need</i> it. But it&#x27;s an <i>immediate</i> 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 <i>literally never make these errors</i> (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.<p>I actually can&#x27;t think of a <i>better</i> way to avoid the class of errors that highlighting instantly exposes.<p>[edit] I do agree with Crockford that extra types of highlighting&#x2F;formatting for readability can be great, including context-based coloring; emacs&#x27;s rainbow parens does something similar based on enclosing parentheses, though the interior of the parentheses is still highlighted in the standard way.
skeohalmost 6 years ago
&gt; Syntax coloring isn&#x27;t useless, it is childish, like training wheels or school paste<p>Disagree with the sentiment behind this. Just because you can read code without syntax highlighting doesn&#x27;t mean it&#x27;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.
评论 #20476394 未加载
评论 #20476373 未加载
评论 #20479357 未加载
评论 #20476156 未加载
评论 #20480758 未加载
评论 #20477257 未加载
评论 #20476262 未加载
crispinbalmost 6 years ago
It&#x27;s so long since I&#x27;ve written any code without syntax colouring, I don&#x27;t even know if it can be turned off in my main GUI tools (IntelliJ &amp; VS Code). When I&#x27;ve occasionally seen code in notepad or an unconfigured vi, it looks like an undifferentiated mess. Which isn&#x27;t to say it wouldn&#x27;t be a useful or interesting exercise to try without it for a while. What we&#x27;re habituated to isn&#x27;t always a good guide for how to proceed.<p>Colouring by nesting level might be useful in javascript, but strikes me as a poor idea in the other languages I&#x27;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&#x27;m happy for deep nesting to be visually confusing - it&#x27;s a useful extra motivator.<p>(Come to think of it, with async&#x2F;await, one of the main cause sof deep nesting in javascript can be minimised also).
flukusalmost 6 years ago
We have indentation for context, the only thing this is really bringing to the table is highlighting variables of the outer context when used inside the inner context. But that only seems necessary because the example is awful code, cramming everything into the return statement. There is also an awful lot of brown there that would have been clearer with syntax highlighting, so even in this contrived example it&#x27;s a mixed result.<p>And if syntax highlighting is training wheels and context colouring is better, does that make it your dad holding the back of the seat?
epicureanidealalmost 6 years ago
What about context coloring the background color and syntax coloring the code? Which maps well conceptually as well.
评论 #20476182 未加载
wayneftwalmost 6 years ago
&gt; I think we can better.<p>What kind of sentence is that? Maybe it&#x27;s saying we can better perform some activity that was mentioned in the previous sentence? Let&#x27;s look at that:<p>&gt; Syntax coloring is very popular, especially with coders who still struggle with basic syntax.<p>So, &quot;I think we can better...struggle?&quot; Hmmm.<p>Perhaps the Crock would have done better with some English syntax highlighting such as the kind commonly found used in spelling and grammar checkers.
评论 #20482111 未加载
dustedalmost 6 years ago
I think context coloring applied to the background would make more sense. In my opinion, the author misunderstood what makes syntax coloring useful. I can only speak from a personal point of view, but for me, syntax coloring is not about hinting at syntax or helping me understand it&#x27;s about improving visual search speed. When I crunch through existing code, looking for &quot;something&quot;, there are multiple things going on. Firstly, I&#x27;m not looking for specific implementation text, I&#x27;m looking for a concept, an idea. So I&#x27;m not actually reading the letters or forming words, I&#x27;m not even looking that much at the length of the words. I&#x27;m looking at the shape much more, and at the shape level, syntax coloring gives a nice hint to what KIND of shape I&#x27;m looking at. When I&#x27;ve found an interesting shape, I&#x27;ll scan for the concept, I still don&#x27;t read everything, maybe a few function names, which are super quick to find, partly because the syntax highlighting makes them stand out, so I can scan to figure out if I&#x27;m at the interesting part yet. When I think I am, I&#x27;ll start executing code: I&#x27;m not checking for correctness at this point, this is not a review, I assume it works, so I ignore much everything that&#x27;s not function or variable names, syntax coloring is instrumental in this too, as it allows me to ignore by color. When I&#x27;m executing fully, the types and other details fly into my mind automatically, partly due to syntax coloring.<p>If I were to turn the table on the author, I&#x27;d say he has a problem keeping track of simple scoping and tries to cope.. I would suggest he turn on the indentation markers in his editor, that&#x27;s what he wants. Though he should be aware that in some languages, context is much more complex than indentation, and that&#x27;s the kind that&#x27;d be interesting to highlight, for example, by changing background color.<p>--<p>Ps, I wrote my first many klocs in windows notepad, so it&#x27;s not like I was brought up on syntax highlighting and can&#x27;t get past it, it&#x27;s just that I&#x27;ve learnt to take advantage of a richer environment (vim).
评论 #20476662 未加载
chowniealmost 6 years ago
I&#x27;m colourblind (protanopia I believe), the context colouring doesn&#x27;t appear to work for me.<p>I can use syntax highlighting to snap eyes to the correct pattern I&#x27;m looking for, I can&#x27;t really discern the value in large coloured blocks of text though. I can already work out what part of code that is by the rough shape of the block before I even start reading it, why would you need to colour it in?