5 ms·
I have a strange use case for syntax highlighting: If you ever forget to close a string or a function definition argument list, or anything along those lines, t
by claudiawerner 5y ago
I have a strange use case for syntax highlighting: If you ever forget to close a string or a function definition argument list, or anything along those lines, the following text will not be colored as usual. This is also why I have automatic indentation enabled, if the indent is put in the wrong place, I know I made a syntax error further up.
In many (most?) languages, you can look at where your code stops being colored and see you forgot to close something like a comment or a paren.
- mseepgood 5y ago> If you ever forget to close a string or a function definition argument list, or anything along those lines Wouldn't the compiler find this and the editor mark it as a compilation error?
- blendergeek 5y ago> Wouldn't the compiler find this and the editor mark it as a compilation error? Syntax highlighting happens in real time. Compiling (at least in my editor), only happens when I say it should.
- klyrs 5y agoDepends on the language, depends on the syntax highlighter. I've seen syntax highlighters that don't make un-terminated python strings look wrong, because the highlighter knows that strings can't span multiple lines (others will give a red squiggly). Some languages give really cryptic errors about the next line -- which gets you in the right neighborhood, good enough for me, but not so friendly for newbies.
- toast0 5y agoI don't know about the person you're replying to, but I'm still old school and don't integrate compiling with my editor; maybe some day it will use a language server and get that for free, but for now it's just language specific configuration that does an OK enough job. When I write a string and the rest of the screen is string colored, it quickly notifies me that I messed up something.
- yunohn 5y agoWhy wait for the compiler? You’re basically saying linting is useless versus compiler errors…
- jonnycomputer 5y agoCompiling isn't always fast. Besides, incorrect syntax will usually interfere with the IDE's code inspection; fix-fast, fix-early.
- u801e 5y agoIt depends on the compiler or interpreter. Some don't give very informative messages and indicate a syntax error on a line that may be one or more lines after the actual error. But the syntax highlighting gives an immediate indication that something isn't right.
- akkartik 5y agoWhere is a function body colored differently than its argument list? (I mostly agree with you. My preferred syntax highlighting is for just comments and string literals.)
- laumars 5y agoThat’s basically the only thing I like coloured: strings and comments. Any more and it becomes distracting visual noise. I’d never lecture someone on whether they have syntax highlighting like the blog post does. It’s dumb to argue personal preference as if it’s fact.
- krylon 5y agoI do not consider that strange. It might be a side effect, but it is very useful, indeed.