Syntax Highlighting Off
robertmelton.com
robertmelton.com
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 luminous or high contrast colors with our eyes, interrupting reading a program in a more standard way..." Half-true. There are well-known pop-out effects, but it's unlikely we read programs the way we read prose, so it's not clear it's an interruption at all.
3) "When syntax highlighting is on you also are spending cognitive energy (which is finite) on item-specific processing rather than organizational processing." No evidence offered. I could just as easily make the counter-claim, that syntax highlighting frees up the brain to more organizational processing, since there's less load necessary to figure out item-specific properties. Not necessarily wrong, but needs to be tested.
I think the biggest mistakes in the article (and perhaps what he got from talking with his friend in the cognitive sciences) are equating prose with code, and not accounting for novelty effects. I have no doubt that coloring random words in prose disrupts things, since it's novel and captures attention. But it doesn't automatically follow that people experienced with syntax highlighting experience similar effects.
It would be cool to see more actual research in this area.
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.
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 likely to accidentally read commented out code as actual code. You're also not going to forget to close out your comment, for languages with paired comment delimiters.
Making strings highlighted makes it a little bit easier to ensure you're terminated your strings, especially in edge cases around escaping and quoted quotes (for languages that have a choice of quote characters).
Semantic highlighting - distinguishing identifiers based on their definitions - is a seriously niche win most of the time, where you're spending ever increasing amounts of CPU for a marginally actionable hint.
when someone builds something they often 'hard code' their own specific interests into the thing
so let's say i am like you, and only want the comments highlighted.. if the highlighter i am using fails to allow me to alter it from the user side of things i'll have to dive into the source
if it is closed then i have to take the time to build my own wheel
if it is is open, but after investigation i find the functionality is hardcoded, piecemeal, and highly specific then i have to take the time to build my own wheel
this is an overly simplistic example of what i am trying to illuminate but from a user's perspective there is a huge difference between these equations:
print(51)
n=3*17
print(n)
a=3
e=17
print(a*e)
a=sys.argv[1]
e=sys.argv[2]
print(a*e)
for highly configurable designs just pulling flags from the command line will get out of hand quickly but it would be superficial to have a function that allows the user to see the programs state and alter it to their needsThis is also a reason that I don't like using editor features that automatically close parenthesis or quotes when you type the opening pair. That may make the expression syntactically correct, but semantically incomplete and the burden will be on me to notice, since syntax highlighting won't help me then.
> What do I miss? Syntax highlighting hinting that I made a dumb typo (importance is directly proportional to compile time or speed of running syntastic).
I'm also not a big fan of overly eager syntax checking because I tend to compose abstractions on the fly, leaving a statement incomplete while I flesh out a dependency, or vice versa. Syntax aware indenting usually breaks badly in this situation - I generally prefer dumb indenting, with an opt-in block or file format option for where I want to fix code over a large area. I've had big fights with Emacs over this; it almost always does the wrong thing by default, whether it's indent location, continuation indent, mixing tabs and spaces in the indent, etc. About half my .emacs is replacement indentation functionality and configuration per mode.
I also don't like auto-completing parentheses, because it puts text ahead of the cursor on the current line. That's a PITA because the editor almost invariably doesn't know when I want to complete the expression or how. Eclipse is the worst at this (it's actually not possible to turn off in a sane way). It interprets RET as completing the expression when I want a line break inside the parens, and I'm constantly having to go back and forth to work around its mistakes.
Funny, because I dislike having syntax errors highlighted for the exact same reason. If I'm typing new code, I like to keep my thoughts on the reasoning behind what I'm typing, and leave it until later to "clean up" the code and get it syntactically correct. Having big red highlights around code that I haven't finished writing yet is a huge distraction... the editor seems to be beckoning to me: "Stop typing and close that paren! Why are you still typing! It's not corrreeeeect yet!!!". And usually it's enough distraction to cut off a good train of thought.
It gets worse when the editor starts complaining about full compilation errors, like calling functions I haven't written yet. When I'm in a more "creative" part of my coding (like when I'm doing lots of brand new functionality), there's a certain ordering of what I write first and what I fill in later, and having an IDE yell at me the whole time is just tiresome.
I find it amusing that now we've got hipster programmers wanting to get back to basics and reject syntax highlighting. Trust me, its not better, colors do make you more efficient.
For languages I don't use much I found having it on more helpful, could I work without it of course, I grew up with computers that didn't have syntax highlighting but I'd miss it.
One side result of the experiment was that I turned down the number of colours I used, not everything needs to be a different colour.
I've tried both and am vastly more productive with it off. Other people haved tried both and are vastly more productive with it on.
I do often encourage people to try whichever one they're not currently using for a month as an experiment to see if they want to switch - calling people hipsters for performing an experiment to try and make themselves a better programmer strikes me as rather depressing.
you're saying that its easier to catch minor syntax errors with syntax highlighting.
this could, technically, be combined. i.e. writing code without syntax highlighting and enabling it for a quick glance to catch these errors that get obvious with the highlighting.
But jokes aside, use whatever environment you like best. For me syntax highlighting is extremely useful. Knowing whether some strings of characters is a type or a variable, or a class type or a basic type makes programming just that much easier. It also helps catching simple typos if something doesn't have the color you'd expect.
By the way, 'em' stands for 'editor for mortals' - I
christened it that after Ken Thompson visited our lab at
QMC while I was developing it and said something like:
"yeah, I've seen editors like that, but I don't feel a need
for them, I don't want to see the state of the file when
I'm editing".
[1]: http://web.archive.org/web/20080103071208/http://www.dcs.qmu...I've always preferred nvi over vim because:
1) there's no lag when I scroll up or down through a file line-by-line,
2) it shows a list of matching files by default when using tab completion in command mode (same as bash), vs picking the first matching filename, and
3) it uses fewer resources when you screw up (http://galexander.org/vim_sucks.html)
I used to think that the lack of syntax highlighting was its biggest weakness, but now that's apparently a virtue :-) .
set wildmode=list:longest
EDIT: Re 3), there's something weird going on.I just tried the benchmark from the article that you linked ("1000000aaeou<ESC>"), and it really did not complete in a useful timeframe. However, when I insert the text once, yank it, then paste it with repeat ("iaeou<ESC>^y4l1000000p"), the operation completes instantly, and I can still browse the file without any slowdown. Undo/redo across this operation seems to take some seconds, though.
Without syntax highlighting I gradually became more focused on the legibility of what I was writing, because none of the visual cues were there when I read stuff back. Function length, module size, naming and vertical whitespace were are all things that I began to think more deeply about.
I turned syntax highlighting back on a few years ago because I was getting so many complaints from co-workers when pairing on stuff at my machine. But I definitely think the experience made me a more considerate, better programmer and I'm glad I did it.
I don't blame you, IMO it's one of the major issues with computer science education. 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. This leaves aspiring developers to figure it out on their own, as you did through turning off highlighting. I'm glad you did, but there are better ways to learn the same concepts IMO.
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", which is stupid.
I'd like to say that's an automatic fail or automatic "don't work at this company" but it's just far too common.
For instance, whenever I write code for public distribution I try to use the same layout principles and code style rules that are popular within my target audience.
Additionally, I try to present concepts in a way that will either be idiomatic to the target audience or at the very least not judged as unusual.
To give a silly hypothetical example. If I were writing code to be delivered to a company that never uses list comprehensions within Python, I'd write everything as an explicit for-in-loop.
This is less of a problem in certain languages where there's explicit global style guides and a tendency to conservatism (Python). Other communities where that's not the case, like Smalltalk, Lisp, and now Elixir, one can see varying control statements and code inheritance methodologies practiced by different groups simply because of how easy it is to implement, and that doing so isn't shunned.
Is spaghetti code clean if it lints successfully?
I can't think of any context where I'd consider spaghetti code clean. It's exact opposite of clean.
Every variable is one or two characters long, the code barely indented, and absolutely no spaces anywhere in the code.
Given that a lot of mathematics involves computer programming these days, I find it remarkable that basic programming principles does not seem to be taught at all.
My point here is that this is not just a problem in computer science education. It seems as though every field that touches on programming fails spectacularly in this regard.
@posts = Post.where(author:params[:author_id].to_i).map{|p|p.comment_count}.select{|c|c>5&&c<10}
I often found myself properly formatting the code before I could even read it.Personally I am working with a white background, so I try to keep the syntax colors all very dark, so while the different colors can be seen, they should not distract from reading. The correct amount of highlighting very much depends from the language at hand, but it can be very helpful in separating elements, just as an example take this function parameter list:
func foo(name, family string, age, size int) {
The correct reading of this parameter list entirely depends on the placement of the commas and the knowledge that "string" and "int" are parameter types - highlighting the type elements can help a lot.
With the availability of high-dpi displays, perhaps colors should be replaced with more traditional ways of markup as used in book-printing, replace coloring with different typesets and fonts.
Low-hanging fruit is the braindead R/G/B/Cyan/Magenta/Yellow used by some terminals in response to ANSI escape codes: https://sdkmvx.files.wordpress.com/2008/08/ansi-colors.png
In my mind, there's three types of colouring: None, Designed-By-Human, and the aforementioned Eye-Searing-255 (which should really be killed off or at least not be the default for anything used seriously). It's disgusting to open source code using vi or similar and have it presented in Eye-Searing-255.
Lol....this. If your primary workstation OS is Windows then I recommend grabbing a copy of MobaXTerm. It has the ability to override and tame the "Eye-Searing-255" beast with its own themes (Solarized Dark and Light, Pastels etc). No more "oh-my-god-my-eyes" when you open up "ooby-doofer.pl" in vim.
Judicious, typographically aware use of bold and italic or oblique in source highlighting can be a wonderful thing.
I do make exceptions. For example, I color my cursor, as well as highlight matching parens if the cursor is on one of the pair (changing just the foreground color of the paren, not inverting it). The only color I use is red.
I don't make any objective claims that this is better, my aim is to make something "done well and tasteful", as you say.
(I really do like having another color on just comments though, code > comments. Separating them makes a big difference when reading source code for me.)
Ended up having to create a Vim color scheme to get what I wanted: https://github.com/ggustafsson/Static-Color-Scheme
I started programming in 7th grade by randomly typing commands into my TI-83 during algebra class. I had no syntax highlighting, auto-complete, or even a choice of font, but I would sit there for _hours_ meticulously making lines jump around the screen.
Now I get stressed out when my color scheme isn't perfect.
On the subject of unusual programming preferences, perhaps antialiasing off would be the next one the author could try. For me completely off is most comfortable, regular grayscale antialiasing is just bearable, and subpixel (like what's shown in his screenshots) just makes me feel dizzy after a short time.
'(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.It's useful to distinguish between language keywords and user specified names. Being able to visually ignore one of them, while focusing on the other, is a tremendous benefit. It cuts down the number of things you need to hold in your head at once, by half.
It's useful to distinguish between local variables and instance variables. It helps to better understand the dependencies that exist between a method and other methods/state.
It's useful to distinguish between mutable variables, and constants. It tells you at a glance how something is being used, and the pitfalls you need to watch out for.
Turning off all syntax highlighting destroys all of the benefits above, and I can't think of any notable benefit you would get out of it.
I guarantee you, whatever "upside" you think you're feeling right now, it's simply the novelty effect. This is a very common phenomenon in AB testing. Often times, you see an initial improvement, simply because users respond positively to the initial novelty of something being different. I guarantee you, if you continue to work without syntax highlighting for 6 months, and then turn it back on for a few weeks, you'll realize how much you actually love it.
He explained his reasoning (and theories why it would work) in enough detail. You might disagree, but I can't see how you can't understand it.
>It's useful to distinguish between language keywords and user specified names. Being able to visually ignore one of them, while focusing on the other, is a tremendous benefit. It cuts down the number of things you need to hold in your head at once, by half.
That's the conventional thinking. The whole point of TFA is that it's not useful -- rather it's distracting, making eyes automatically focus in such distinctions while losing the bigger picture.
Plus, just because you've colored "language keywords and user specified names" doesn't mean it's now easier to "visually ignore" one of them while focused on the other, it can mean the exact opposite: the extra color distraction makes you jump from one to the other -- unless you put extra conscious effort.
From a physics/math perspective, yes, I get that "more" implies more entropy. Having 4 colors on your screen is more entropy compared to 2 colors. Having 7 letter names is more entropy than having 2 letter names. But if that additional entropy is used to convey clear, unambiguous and useful information, it actually makes the overall message simpler. The same way that long/descriptive variable names make reading code simpler compared to random 2 letter symbols.
On more reflection, the one reasoning I can somewhat understand, is the idea of handicapping yourself. If you force yourself to type with one hand behind your back, it gives your brain additional incentive to find concise solutions. In theory, I guess I understand this line of reasoning, but in practice, I'll still continue typing with both hands, thank you very much.
Anyway, just thinking aloud here. When I come across something I don't understand, I try my best to understand what the other side might be thinking. Not trying to attack anyone... to each his own. Best wishes.
With human language like English, we learn it and use it without the formal grammar++. A 5-year old child can speak to her mother ("I want some candy!") without conscious knowledge of "verbs" or "nouns". A formal grammar for categorization is what we layer on top of language for analysis in school. Two people can communicate and understand each other without any exposure to any grammar lessons. So yes, colorizing verbs looks superfluous and noisy.[2]
On the other hand, computer programming syntax starts with grammar. You learn that certain specific tokens are "data types" and other tokens are "literals", etc, etc. And that grammar categorization in programming languages never goes away as you're typing out new code. (Otherwise, you'd get a compiler error or unintended behavior because x="3"+"5" with quotes ("35") means something different from x=3+5 without quotes (8).) This is why so many programmers find color highlighting helpful even if they've been programming that language for 10+ years. Sure we want to focus on higher cognitive purpose of "semantics" but the grammar is deeply intertwined with reconstructing what the semantics is.
A closer analogy of color highlighting in a different realm would be different colors in TCPIP traces such as "red" highlighting external ip addresses. This can be helpful for forensics of malware phoning home.
Or in financials dashboards where uptrends are "green" and downtrends are "red".
The same reasons that colors help the malware analyst or stock trader quickly parse data at a glance is also how it helps programmers.
++ (at least not consciously that a 5-year old would be self-aware of it. A theory of innate universal grammar in the brain by Chomsky isn't what I'm talking about.)
[2] except for rare examples of using annotation or coloring of verbs to help parse sentences like this: https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal...
as one of the comments here quoted: "syntax highlighting, while aesthetically seductive, moves focus from content to form". Sums up the state of art in 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 who don't use it. One of those choice things.
Some examples:
1. Linux Akesson (LFT) wrote an article quite some time ago about it: http://www.linusakesson.net/programming/syntaxhighlighting/
"A case against syntax highlighting:
Do you rely on syntax highlighting when developing software? If so, you may be shooting yourself in the foot. In this post, I will argue that syntax highlighting, while aesthetically seductive, moves focus from content to form, and discourages those who look at the code from trying to understand it."
2. The Acme text editor does not support syntax highlighting and probably never will. Prominent contributors to golang use this editor.
On my own, I started to program without syntax highlighting, then used it and now I use a much weaker one. I like to be able to track individual variables by color as a form of semantic highlighting and to bring up comments rather than dimming them like it's often done.
If we compare this with classical text, we won't have any typographic help for the inner structures of sentences, maybe simply because colouring different types of words differently was quite hard. Typography there is used for the outer structure. Mostly vertical space is used to separate paragraphs. This is also used in programming. However making headlines bigger and use a different type isn't used in programming. Programming uses indentation instead. It is pretty obvious that it's this way because of the limitations of the medium in the beginning. Also it's not as easy as classifying tokens.
My experience is the opposite: I use syntax hilighting on Emacs, TextMate, and the JetBrains IDEs. When I SSH to a server and use Emacs to edit code, I find it jarring if syntax hilighting is not set up for whatever programming language I am editing. I can't read and understand the code as fast.
I started using syntax highlighting still in the MS-DOS days, and hate when I am forced to downgrade my developer experience.
But to each its own I guess.
It's also nice to have low opacity comments, as many others have said.
Oh, and never bright colors. I use solarized or similar.
Did anybody else go from needing a white background, to preferring a dark one?
(I had the zebra effect for years when trying to read light-on-dark, then one year something changed--I don't know exactly what.)
A white background was never preferable to me. So dang bright.
I started on with gray on black (BASICA) and yellow on black (Turbo Pascal 2.0). Later on things like Q-BASIC used gray on blue (which I would occasionally change to green on black), and the Borland IDE's continued with a blue background, but added syntax highlighting.
When I made the move to Windows and Visual C++, back we went to white backgrounds. Yikes. Xcode does this as well by default.
"one year something changed - I don't know exactly what" - you matured:)
In Haskell I have different colors for the comments, keywords, and literals. That's it. Anything more is not helpful.
It's baffling to me to look at source on Github and see a screen full of comments, greyed out.
The code is what is hard to read, comments are easy to read. I want help focusing on the code, I don't mind if the highlight structure doesn't help me read the comments as they are more than easy to read already.
At best, they are a statement that, at the time they were last edited, the author believed their stated facts were true, or might become so, plenty are aspirational, "this is what this function or change to it, which I've not yet written, will do".
He might have been wrong, or the code might have changed without updating the comment, the actual running code is the only truth.
But generally commit messages, descriptive symbols, simple logic, short functions, and unit tests are better.
nmap <F11> :if exists("syntax_on") \| syntax off \| else \| syntax on \| endif \|<cr><C-g>
nmap <F12> :set wrap! wrap?<cr>
My personal productivity boost :)Never question someone's credibility because their preference differs from yours. It'll make people question your credibility.
Of course, legible code is more important in most cases.
One could make the opposite argument that comments are the important part and you only need to read code when diving in. This would be sort of a literate coding. I'm torn between making comments dimmer or brighter.
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?)
It also helps with instantly seeing if you are missing a "/' (or used the wrong one to terminate a string variable), as the rest of the line/file has the wrong colours.
I'd also point out turning off highlighting may produce a false perception if the color scheme you're switching from is mediocre or worse (as most of them are in my experience). To a starving man McDonalds tastes like heaven. Properly implemented syntax highlighting shouldn't be distracting in the first place. If you're using syntax highlighting and have trouble reading code line-by-line then that's just a sign you need a better color scheme IMO. I switched from some random theme I found online to solarized-dark a couple of years ago and found it made the reading experience much smoother.
At any rate I'm glad he's found something that makes his programming more productive and enjoyable, but I would avoid categorizing it as objectively better, as the author tries to do.
It would be a pain to turn highlighting on/off since I switch modes rapidly and often. But I can image a mode where it changes highlighting based on scrolling speed. It would be easy fade the CSS colors to/from B/W on the fly.