by jgorauskas on 9/28/14, 2:51 AM with 23 comments
by Crito on 9/28/14, 5:12 AM
Personally, I do find syntax highlighting to be useful, but I think it is an interesting dissenting opinion that is worth mentioning. OP's article mentions that Acme doesn't have syntax highlighting, but doesn't really expand on that.
by jhallenworld on 9/28/14, 3:47 PM
JOE's highlighter supports recursive calls: for example to switch syntax to a scripting language embedded in HTML. Originally I implemented this with template instantiation of the sub-syntax. Recursion is allowed, but to a limited depth: the advantage is that the state can still be represented as a single number.
Later, this was replaced with a real call stack. It turns out that the call stacks of the saved continuations are often identical (stated another way- there is already an identical continuation, so when there is a call, we search for and reuse it if found).
The continuation also includes a buffer for saved data (for example for here document delimiters). The continuation ends up being 32 bytes on 32-bit machines:
struct highlight_state {
struct high_frame *stack; /* Closure */
int state; /* Program counter */
unsigned char saved_s[24]; /* Local data */
};
Anyway, it's at least conceptually straightforward to extend this to have any kind of state. Also, it should be possible to compile the syntax parser to the native machine code. Even so, the interpreted implementation is quite fast. Fast enough that there has not been a need to try to run it asynchronously or after a delay as in some other editors.by drothlis on 9/28/14, 8:19 AM
by noir_lord on 9/28/14, 3:56 PM
As someone who started in an era when syntax highlighting didn't exist (at least on the machines and tools I was using at the time) I personally like it a great deal.
I found something the other day in the intellij ide's that I really liked (and had not seen before though I may have missed it) which was the ability to highlight the variable under cursor contextually (different for reads and writes).
Like so http://i.imgur.com/u9UkXPN.png
It was a small change but when running through code you've not used/seen before I've found it a nice little touch at getting a good grasp of whats going on with variables.
by platz on 9/28/14, 6:19 AM
This would be useful in langues that make heavy use of callbacks such as javascript or scala.
Not sure how hard it would be to implement though - it might require a full parse or compiler pass.
by arianvanp on 9/28/14, 8:40 AM
by micampe on 9/28/14, 5:07 PM
Or maybe syntax highlighting for the scope I'm in and structure for the rest.
I often use the folding/nesting indicators when reading code, it would be an extension of that.
by visarga on 9/28/14, 5:20 AM
by signa11 on 9/28/14, 12:38 PM
by icantthinkofone on 9/28/14, 1:09 PM
You've read that the best programs read like a book. Now picture a book you are reading where the title, subject, nouns and verbs were all colored in some way. Try and read smoothly through that forest and think about highlighting some more.
There are a number of articles about reading on the web and how you highlight links without interrupting the flow of the reader. Should you underline links, or make the word a different color or give it a background? No matter what is done, it's said, you will interrupt the reader's flow and train of thought. Here, though, people exclaim highlighting is beneficial because function names, variables, values, and so on are highlighted and this is good!
Now someone will claim highlighting helps them find a particular value, say a function name but isn't that what indenting is supposed to do? Others will now say it helps with arguments but isn't that parentheses are for?
If you look at most multi-colored, highlighted page of code it looks like a candy store, all of it begging for your attention which is exactly what you don't want. Those with muted colors and grays are no different when you're trying to pick out one slight variation over another and trying to determine if it's a function or something else.
When I read a book, I want paragraphs with indentation and I can read pretty fast that way. So can you. When you read code, you need blocks and indentation (and parenthese/brackets/semicolons). Little else. Maybe nothing else.