3 ms·
For what it's worth, I said no to syntax highlighting three years ago and never looked back. Anecdotal, but I'm making much less errors and paying more attentio
by fao_ 8y ago
For what it's worth, I said no to syntax highlighting three years ago and never looked back. Anecdotal, but I'm making much less errors and paying more attention to the code, now.
I think a lot of code highlighting is basically ineffectual, though, given that it (almost always) highlights based on keyword-based regex, rather than the semantic meaning of the code.
- stuross 8y agotake a look at https://github.com/tree-sitter/tree-sitter https://github.com/tree-sitter/tree-sitter
- jakear 8y agoI use it as visual feedback from the parser. That is, if I’ve messed up a bracket placement while moving code around, all the code after that will be colored “oddly” and I can instantly tell both that I’ve made a mistake, and often where exactly that mistake is. I contest that they highlights based on keyword-based regex too. I haven’t formally analyzed TextMate grammars, but I believe the scoping behaviors take them into context free grammar territory.
- zephyrfalcon 8y agoGranted there isn't much to be gained by making your code look like an angry fruit salad. But I do find it useful in some cases, e.g. to make comments stand out from the rest of the code. Also, unterminated block comments or strings will immediately show up as well. And if you are not very familiar with a language, it might help to highlight keywords, so you don't accidentally use them as variable names.
- astine 8y ago"Anecdotal, but I'm making much less errors and paying more attention to the code, now." Could be correlation rather than causation. Presumably, you're a more experienced programmer now than you were three years ago and you might be making fewer errors and paying more attention regardless of whether you turned off syntax highlighting.
- rspeele 8y agoDo you miss highlighting for string literals? I don't think I would care one bit if my syntax highlighter stopped making keywords blue and type names green. But damn, would it get frustrating not having dumb quoting mistakes stand out right away. I like fixing those based on immediate visual feedback as I type, vs looking at a surprise compiler error next time I try to build. Which of the below string expressions (C# as example language, many are similar) has a mistake? 1. "Most strings are " + easyOrHard + " to read and " + concatenate + " with variables 2. "Some, like \"" + onesWithQuotes + "\" are trickier" 3. "Your friend \" + friend.Username + "\" has joined the chat" 4. @"In C# multiline string literals denoted with @, \ is a legal character on its own and """" is used to escape the "" character" 5. @"You're probably a jerk like my buddy """ + name + "" if you mix syntaxes like this"
- fao_ 8y agoI like using C's string gluing thing: > printf("this is a test\n" > "this is \"another\" test\n" > "hello world\n"); You're right though, I do have to pay more attention in strings. Paying more attention doesn't seem like a negative thing to me, though.