Live data from Hacker News

Syntax Highlighting Off

robertmelton.com

101–110 of 110 posts

Re: Syntax Highlighting Off

#102
post #71

Former neuroscientist here. Please take this article's pop science proclamations with a grain of salt. 1) "Additionally, we process words much faster than we process colors". Wrong, I'm pretty sure areas V2/V4 received information much faster than the visual word form area, especially given that it may require a saccade to take in a long word. Not sure where this claim comes from. 2) "...we instinctively jump to lumi…

Excellent points. What I would add is that he talks about finite cognitive energy, but nowhere in the article mentions how highlighting helps to save the very same cognitive energy.

For example, if there's a comment in the code, without highlight you would need to follow the comment and look for closing quotes. If the comment contains escaped quotes it becomes even more difficult. With highlight you immediately see where it ends.

Another example are keywords - when they are highlighted, you don't even need to read it. You glance at them and know the meaning by their shape. While without highlighting you would have to read every single one of them to understand that they are in fact keywords and not something else.

Re: Syntax Highlighting Off

#103
post #2

"Reading code is simply more straightforward, smoother and less jumpy. I get the overarching context faster and with less hassle." This makes me think the author might be one of those people who can not superficially scan text very efficiently and resort to.. well, just reading it, word by word. (Is there a term for this phenomenon?)

Having highlight off forces him to focus on the code really hard, which may make it seem like it is helping him to understand the code. And looking at his code examples, he really needs it, so good for him.

Re: Syntax Highlighting Off

#104

Earlier quoted context omitted.

Perhaps you should use a less ambiguous term than "clean". They're giving you a correct answer, so perhaps you should ask the correct question? "Is your code readable", perhaps? "Are you proud of your code?". Something like that. No-one's going to admit their code isn't clean, regardless of how they interpret that term.

>They're giving you a correct answer Is spaghetti code clean if it lints successfully?

Yes. And no. Depends on the context. Microsoft and malware coders both think windows is great for the same reason; it's very popular.

Re: Syntax Highlighting Off

#105

"One of the basic rules of thumb in typography is that, when writing a piece of text, you should choose one typeface and stick to it." How about an analogy from cooking, too? "It's easy to spot all the verbs, but why on Earth would you want to do that? " Well, exactly! Makes it obvious how stupid your argument is, huh?! I'm pretty sure the people who choose syntax colouring know what they're doing, just like the ones…

... sorry but syntax highlighting on spoken languages for parts of speech would be CRAZY useful when learning to read that language.

Re: Syntax Highlighting Off

#106

I do something very similar (grey strings/comments, some bold/underline identifiers): http://i.imgur.com/i5j0QKT.png

I really like that colorscheme, care to share it?

Hmm not sure if this is exactly what you are looking for, but this is the relevant section in my CUSTOM-SET-FACES:

  '(font-lock-builtin-face ((t (:weight bold))))
  '(font-lock-comment-face ((t (:foreground "#707470"))))
  '(font-lock-constant-face ((t (:underline t))))
  '(font-lock-doc-face ((t (:inherit font-lock-comment-face))))
  '(font-lock-function-name-face ((t (:inherit font-lock-constant-face))))
  '(font-lock-keyword-face ((t (:weight bold))))
  '(font-lock-preprocessor-face ((t (:underline (:color foreground-color :style wave)))))
  '(font-lock-string-face ((t (:foreground "#707470"))))
  '(font-lock-type-face ((t (:inherit font-lock-constant-face))))
  '(font-lock-variable-name-face ((t (:inherit font-lock-constant-face))))
  '(font-lock-warning-face ((t nil)))
  '(fringe ((t (:background "#ffffff"))))
  '(glyphless-char ((t (:slant italic))))
  '(highlight ((t (:weight bold))))
  '(isearch ((t (:box (:line-width 1 :color "#000000")))))
  '(isearch-fail ((t (:weight bold))))
  '(italic ((t (:slant italic))))
  '(lazy-highlight ((t (:box (:line-width 1 :color "#d0d4d0")))))
  '(link ((t (:inherit button))))
  '(link-visited ((t (:inherit link :box (:line-width 1 :color "#707470" :style pressed-button)))))
  '(minibuffer-prompt ((t (:weight bold))))
  '(mode-line ((t (:inherit mode-line :background "gray93" :foreground "#000000" :height 110 :family "Source Sans Pro"))))
  '(mode-line-emphasis ((t (:underline t))))
  '(mode-line-inactive ((t (:inherit mode-line))))
  '(mouse ((t (:background "#000000" :foreground "#ffffff"))))
  '(region ((t (:background "#d0d4d0"))))
  '(secondary-selection ((t (:background "#e9eee9"))))
  '(show-paren-match ((t (:weight bold))))
  '(show-paren-mismatch ((t (:underline t))))
Other than that I use the Inconsolata font.

Re: Syntax Highlighting Off

#107

Earlier quoted context omitted.

>They're giving you a correct answer Is spaghetti code clean if it lints successfully?

Yes. And no. Depends on the context. Microsoft and malware coders both think windows is great for the same reason; it's very popular.

>Yes. Depends on the context.

I can't think of any context where I'd consider spaghetti code clean. It's exact opposite of clean.

Re: Syntax Highlighting Off

#108

Earlier quoted context omitted.

Yes. And no. Depends on the context. Microsoft and malware coders both think windows is great for the same reason; it's very popular.

>Yes. Depends on the context. I can't think of any context where I'd consider spaghetti code clean. It's exact opposite of clean.

Clean...in the sense that it passes lint, unit testing, continuous integration etc. Not clean in the sense that "internet user #1209828 approves of its aesthetics", which is a metric subject to fashion, opinion etc.

Re: Syntax Highlighting Off

#109
post #24

I'd freely speculate that 90% of the benefit of syntax highlighting comes from mere lexical highlighting - specifically, making comments, strings and keywords visually distinct from everything else. And even keyword highlighting is very secondary to the first two. Making comments distinct from normal code is nice because you can easily alternate your focus on one or the other while reading through; and you're not lik…

I wasn't aware there was anything more to syntax highlighting than what you are calling "lexical highlighting" - what I think of as "syntax highlighting" consists of coloring comments, string literals, and reserved words differently than identifiers or punctuation marks. So, I gather that there must be some editors which use more complicated schemes; can you point me at an example?

Re: Syntax Highlighting Off

#110

Earlier quoted context omitted.

>Even basic principles of clean code are often neglected or never taught, in large part due to the lack of professional experience in academic circles. There's a lack of experience in professional circles too. One of the questions I always ask during programming interviews (on either side) is "is your code clean? if so, why?". Invariably the answer is a variant along the lines of "if it passes the linter it's clean",…

Perhaps you should use a less ambiguous term than "clean". They're giving you a correct answer, so perhaps you should ask the correct question? "Is your code readable", perhaps? "Are you proud of your code?". Something like that. No-one's going to admit their code isn't clean, regardless of how they interpret that term.

Leaving the definition of "clean" ambiguous does give you some useful information, though, because the context implied by the answer shows you something about the interviewee's priorities. Of course their code is "clean" according to whatever metric is important to them - but what's their metric? What are they focusing on as they work?
Post reply on HN