I’ve never felt that syntax highlighting added or detracted much value. The main value I gain from it is this: When half my file turns a single color, I know where I forgot to close a quote.
[Comment removed by author]
I use syntax highlighting mainly to separate code into partitions that are easily scannable. Here’s an example of a theme I use for that, that somewhat matched what you wrote above: https://github.com/aerique/emacs-theme-aerique
I feel this opinion won’t be popular but… this reads like another case of bias confirmation after as little as trying to pay more attention to one’s own code. I’d like some data for a change, not “I felt that I understood my code better”. Otherwise it’s the same feeling you get about your computer being faster after you wiped the dirty screen after a while.
I think the article is right in asking people to try for themselves. I’ve used Acme for a couple months as my text editor at my workplace. This gave me the opportunity to use it for proper work while keeping Sublime Text at home for hobby projects. While I loved Acme’s particularities (tiling, mouse chords, unix terminal with plan9 utils.. on windows!) I loathed the lack of syntax highlight.
I didn’t really feel different with my code after taking aways colors, but I noticed both while and after not having it that I was making a lot of mistakes that syntax highlighting would have prevented (unmatched quotes, wrong braces).
In the end I went back to Sublime, however I’m trying to fill the gap left from Acme with some plugins for tiling and plumbing.
On the other end, I’m so dependant on my tools now that I’m used to not indent Go code on purpose because I use “gofmt-on-save” as a linter. (if it doesn’t indent it, it’s broken)
Good point with the indenting. Apart from coloring, that’s the other thing that tells me the parser and I disagree on what I wrote.
The strongest argument I have is that highlighting English actively makes it more difficult to read. Perhaps this is because we’re used to reading prose without highlighting, but even “lightly highlighted” text like this Sherlock Holmes story is infuriating (scroll down halfway to see some quoted strings).
I made this comment on lobste.rs last time highlighted prose was used as an example:
Not a big fan of that image of real lit using syntax highlighting. In programming, we use tons of repeated elements like braces, colons and keywords like for, while, if, import, and hundreds of others, depending on the language. Each if statement will use the exact same keywords. Syntax highlighting can help show us what words really matter and which ones are just syntactical filling inherent with the language. In a novel, each verb conveys vastly different meaning and needs to be read in depth.
I made a long comment, in that same thread.
I no longer stand by it. I think it was unnecessarily divisive, and all my complaints came down to “there are no themes I like”. The solution to that is to make one, not to complain about it. And I have found that I do find coloring very useful to add visual texture to code, so that I don’t lose my place in it as easily.
I tried it and I think there’s something to it. I recommend everyone just try it for a few days.
I think that comparing the effectiveness of highlighting for spoken languages and highlighting for programming languages is comparing apples to oranges. We don’t read code the same way we read English.
A better parallel, in my opinion, would be syntax highlighting for a complex mathematical equation, in which case I think you would find it would make it much easier to understand and read.
I think using different colors for different variables might be useful with mathematical equations, but I doubt it would help to color variables one color, operations another color, functions a third color, etc., as we do today with code.
Crockford suggested a syntax highlighting where each scope was its own color.
I’ve seen a lot of structural editors for Lisp do things like this over the years. I don’t go that far, but I do highlight parens depending on nesting level, and it can be very helpful.
I actually use a vscode extension that adds this called “indent-rainbow”
In college I used a four color pen. I soooo used syntax highlighting as a way of keeping context like this on paper for many many mathematical constructs - matrices, graphs, equations, what have you. I even have a syntax highlighted regex set on paper filed somewhere in my room still.
Sure but in programming the grammar is a part of the meaning. In english the grammar is usually not relevant.
Edit: Amusingly the highlighted english was much easier for me to read. I have ADHD and often lose my place, and the color helped me keep track of which word I was on.
I legitimately think highlighting English makes it easier to read. You can easily pick out the subjects, objects and verbs easily and I think if someone was learning English the highlighting would be very helpful.
You know we actually do use ‘syntax highlighting’ in english in the form of underline, italics etc.
It’s just that this particular application of highlighting is awful, since it’s a transplant from code highlighting.
I don’t know about you, but I always feel like my computer is faster after I download some more RAM.
I was a kid, and I thought I knew stuff about computers. So when Connectix came out with this product called “RAM Doubler”, I giggled. What snake oil! But then we got a copy and lo and behold, I could run more programs than I had memory for! I was totally astounded.
Years later, having long forgotten about this, I was in my operating systems class, and I learned about virtual memory. It all snapped into place: RAM Doubler was a kernel extension that implemented virtual memory, which Mac OS didn’t support back in those days.
More details: http://www.ambrosiasw.com/Ambrosia_Times/January_96/3.1HowTo.html
IIRC, RAM Doubler also did memory compression in later versions. Maybe they also did black magic with the way memory management worked with contiguous blocks - the classic System had trouble with that. Their later companion product, Speed Doubler, replaced the 68k emulator on PPC Macs with a JIT, which improved performance because almost everything back then was emulated.
Totally agreed. Basically I found myself thinking “I paid attention to my code more” is the crux of the article.
“I got bored so I decided to turn on hard mode.”
I have real trouble with syntax highlighting. It makes everything unreadable to me. I can’t read most websites that display code because of the highlighting. Of course, acme, my text editor, lacks any syntax highlighting.
It’s interesting that I didn’t start like this. Before I discovered Plan 9, I used highlighting (usually) just like everyone else. I didn’t turn it on, but it was usually on by default in the vim configuration shipped by Linux and off by default in BSD’s nvi (or simply lacking the original vi shipped in Solaris). But if it wasn’t on already, I didn’t bother turning it on.
Now after I stopped using syntax highlighting for many years (close to a decade now), I simply can’t read code with highlighting on. If some colleague wants some help with some code, my first request is to turn nightclub mode off.
Oh yeah, I program using a proportional font too (Lucida Grande, 14 point): http://i.imgur.com/XovEU4g.jpg
Project Fortress (a programming language research project) proposed mathematical syntax for programming:
The idea of “typesetting” the code using LaTeX has received mixed reviews, and many potential users find the issue of keyboarding the extended Unicode character set daunting. Nevertheless, even in its more verbose ASCII form, the syntax of Fortress, especially the notion of treating juxtaposition as a user-definable operation, has proved to be very convenient.
I have used unicode greek characters in my code, which I find very helpful, especially when doing scientific programming. My colleagues didn’t like that however and the toolchain was complaining too.
I think that this might be unpopular and it’s certainly a bit bold, but I often thing that becoming a programmer rather than a mathematician has a lot to do with mathematical notation.
Also I want to point out that there is APL and that despite of my previous statement I’ve seen impressive things done with it.
Ken Perlin wrote a small post arguing that one approach is more procedural, while another is declarative (setting up a state of the world and shifting the world while preserving correctness).
As for APL, I wrote k professionally for about a year, and am happy to talk about that experience.
I’d be interested in hearing about professional k usage!
It’s been a while, but here are a few observations about k:
[x[i] for i in indices]
That was really insightful. Thank you!
I am not an acme user, but I considered trying it. What I always wondered about with those self-made commands. Are there like collections of them? I know they aren’t hard to make, but I think a collection could give you ideas, starting points, etc., kind of like a vim plugin or config. Even if I don’t go with huge packages usually (be it vim or zsh), I kind of like ideas that you find while looking at existing stuff.
Or is that generally discouraged for some reason and never fell important?
Acme users (all 10 of us) write their own commands when they need them. I don’t know of any collection of commands, sorry, what would be the point? Every environment is different. The philosophy behind acme (plus plumber) is that it’s an integrating environment of arbitrary Unix software (I’m counting Plan 9 as a Unix here), not an integrated environment. It makes it really easy to integrate any reasonably written Unix tool into your workflow, but it doesn’t really provide any such built-in integration by default.
You don’t need any collection of commands to use start using acme though. Usually on every new project I start with a blank environment. I add stuff to it only as needs become apparent.
Okay, this is what I expected. I just wondered whether my assumption was correct that people do it that way. Also wondered if there are some scripts, not so much for reuse, but as example, so “smart tricks” on how to do something in a simple way, because I like to read code. :)
It’s pretty common to have a+ and a- for increasing/decreasing indentation, and c+ and c- for commenting/uncommenting. Beyond that I’m not aware of any conventions.
I have obtained some of mine from other people. Someone on a different lobste.rs thread shared Clear with me (to wipe a terminal).
Edit ,d will clear a window (including a terminal).
That’s what I used to do, but Clear is easier to middle click, and it keeps my prompt.
Holy tag batman! ;)
I often program without syntax highlighting and it doesn’t cause problems. If anything i would advocate for maybe a slight graying out of comments, and that is about all.
I don’t understand this. Almost all color schemes for editors out there try to hide code comments.
I do consider code comments to be essential. If they are meaningless they should not be there in the first place.
It’s not an effort to make the comments unreadable, but just to make a clear distinction between what is code and what isn’t.
The code is always the source of truth, comments often lie. I’d rather my eye drawn to the code first, as its what I’m working on, then to the comments secondarily.
Comments should be treated just as code. If the comment is false the code is faulty. I know that there are loads of examples where this is not true, but just as I think that patches should include patches to documentation, comments should be maintained as well.
This may lead to a situation where comments are used more sparingly in the critical sections of a code block and not like badges where the intern has laid his/her/its hands on.
They should be, but i still haven’t seen a compiler capable of checking comments.
That’s beside my point, compilers also don’t check documentation. And they certainly cannot check for code correctness.
…my coding style changed. I was structuring my source better
My friend switched to using Acme and reported that no highlighting made her a better programmer because she didn’t rely on colors to find mistakes and wrote code that was better organized and more readable. It sorta makes sense that this would happen, but I don’t know if I am ready to try it out for myself. Syntax Highlighting makes code very readable to me and easier to find mistakes. People added that feature to editors for a reason after years of coding without it.
I found quite a time ago that full syntax highlighting just distracts me, so I configured vim’s limelight plugin to stretch the highlighting for two paragraphs; which gives exactly what the author describes: limited, conditional highlighting. (limelight was designed with more textual input in mind, but still works great with my python/ruby/bash code).
I found it wasn’t necessarily syntax highlighting that I didn’t like, but syntax colouring. To that end, I’ve been using an eink-based theme for several years that has minimal highlighting and no colouring — strings are underlined, comments are shaded, and in the emacs version certain things are bold-faced. For me, I found a lot of colouring was visual noise that was distracting.
Back in 2007 I experimented with an idea I had for a while, a so called fisheye editor: http://apgwoz.com/fisheye-edit/
The basic idea was that you should see what you are working on now, and only the structure of anything else. As a prototype it was successful, and I liked the way it felt, but I never did try to write fisheye.el to get more realistic data.
I’ll copy what I wrote on HN:
This seems to be an over-reaction to overly highlighted code. I work with Erlang in Emacs, and at first I couldn’t believe how much of a Christmas tree my code looked like: every token had its own color, and it was really hard to read. Fortunately, erlang-mode has a setting to reduce the amount of highlighting. I don’t think the proper reaction to a code base that has too many colors is to have none at all: trop c'est comme pas assez. I think many would be happy with some limited highlighting, for example comments, strings, and other constructions that can span multiple lines, incorrect escape codes, possibly-misspelled identifiers, etc. I don’t really need or care that keywords and integer literals are colored differently.
I should really get off my ass and create an Emacs theme where only a few select constructs have highlighting, and the rest stays with the default color.
I dont know if syntax highliting makes me understand code better, but I must say that, being really lazy about configuration, I’ve never found that I understood code any less without it.
It has an opportunity cost. Not highlighting parts of speech except comments and literals allows me to spend limited spectrum on more useful things:
a) Multiple colors for different kinds of comments.
b) Highlighting dataflow.
If anyone is having trouble finding the live demo in the second article, this is the link: http://evanbrooks.info/syntax-highlight/