Live data from Hacker News

Syntax Off (2012)

kyleisom.net

41–48 of 48 posts

Re: Syntax Off (2012)

#42
post #36

Is using and tags syntax highlighting for text? Personally I program Clojure, so there's not a lot of syntax to highlight--well, more than in scheme, for example--but I couldn't imagine life without brace matching (a dynamic kind of syntax highlighting).

A particularly useful plugin for a type of paren matching a lot of people curiously don't know about is Rainbow Parentheses http://www.vim.org/scripts/script.php?script_id=3772 (example: http://i.stack.imgur.com/Hlctr.png)

Re: Syntax Off (2012)

#43
post #11

It reduces productivity and adds headache. Code is not a textbook. A good programmer has to always look at different pieces of code and would lose himself in the mess of symbols if there is no indents and block highlights..

Well, even textbooks often use colors, fonts, emphasis and other mechanisms for the same thing we use it in syntax highlighted code.

And if he's meaning to compare it to prose, while they typically lack color (due more to the means of printing than the format, check out old manuscripts and they use color quite often), they use punctuation and other methods of emphasis like bold, italics, size, and underlining.

Re: Syntax Off (2012)

#44
post #35

> The lack of syntax highlighting was a bit of a shock at first, but I found over a day or two that I began to get used to it. Once you're used to the lack of color, go all the way and use a proportional font.

Don't forget to drop the indenting as well.

Re: Syntax Off (2012)

#45

Ever since I spent a week wondering why my main loop only ran 3 times, I always turn syntax highlighting on. This is what my code looked like: // Initialise for (i=0;i Syntax highlighting would have shown the problem instantly. In fact, the bug would never have happened. Anything that can increase the chance to catch an error is a good thing. [EDITED for code formatting.]

This is a fantastic example! Took me having to turn on code highlighting to catch it.

Re: Syntax Off (2012)

#46
I've found syntax highlighting is good at making the structure of code evident, which in turn makes it much easier to grasp the general idea of a snippet at a glance. This is a very important property!

Code is read more often than it's written, but it's skimmed more often than it's read. So making it easy to mentally jump around code without actually reading it is extremely valuable.

I've found this particularly valuable in Haskell because it lets you use arbitrary things in infix position. Now, this by itself is valuable for the same reason: it helps structure the code, neatly separating the operation from its arguments. Some things just make more sense infix. But visually, it's often hard to grasp when something is infix. This is not too bad with operators:

    foo bar baz + qux 11 quux
but it's actually rather difficult with normal words infix:

    map solve problems `using` rpar rseq
Now compare this to the highlighted version: http://jelv.is/img/hs-syntax-hl.png

The most important part of the above snippet is how "using" divides into two clear parts. And yet, on something like HN, this is a bit hard to follow: "using" looks like another word in a string of words--this is exactly what I want to avoid with the infix syntax!

In Emacs, at least, infix symbols--both operators and names in backticks--get highlighted in a different color. This immediately make the structure of the above code completely clear. Then, when I'm glancing through it, I can focus on the part I care about. (This example is particularly appropriate because the two halves do completely different things--the left one defines the computation and the right one specifies how to parallelize it; chances are I only care about one of the two at a time.)

I think that highlighting operators also explains why I've never had any real difficulties with Haskell's "symbol heavy" code.

This could be extended to a bunch of other structural distinctions I care about. For example, when reading Lisp code, I would love to have macros and functions highlighted differently. Macros generally represent some sort of code organization where functions are often part of the actual program logic; moreover, macros and functions behave very differently.

Re: Syntax Off (2012)

#47
post #30

> When I read a book, I don't want parts of speech highlighted in different colours Books don't have syntax highlighting, but having never read a book that does, I can't say one way or the other that it is a terrible idea. And actually, as I think about it more, books would be a nicer reading experience if conversations were highlighted, and if key person/place names where in a different color. (Just like text in RPG…

And I'd argue that if books did have syntax highlighting, parts of speech wouldn't be the best way to inflect it anyway. Maybe give a colour to each each character, or each location, or even just the subject of a sentence. Which "her" does this refer to? Which speaker is this? These are all potentially valuable things.

And some books do do these things. Often thoughts are italic whereas spoken words are quoted. Pratchett puts Death's words in all caps.

Re: Syntax Off (2012)

#48
post #32
post #25

"When I read a book, I don't want parts of speech highlighted in different colours" I do! In long conversations in novels I occasionally lose track of who is currently talking; normally it's really obvious as the next page of text doesn't make any sense until I backtrack to find where the speech got switched, though one time I finished a whole book where my protagonist had the wrong gender because I didn't realise th…

> In long conversations in novels I occasionally lose track of who is currently talking Perhaps the actual story narrative needs to be clearer, by repeating the speaker's name more often.

It's amazing how often fiction doesn't even indicate the speaker once (in any given dialogue), and just leaps into conversations by simply starting them, relying on context and "voice" to identify the speaker, alternating back and forth with other speakers with no intervening description.

I don't seem to have much problem with this in English, but it causes me no end of grief reading in a non-native language, I suppose because my grasp of context and eye for other cues is much shakier...

[I've read books where I'll get halfway through the book before realizing my entire conception of what's going on has been completely wrong due to confusion over who said something in the beginning of the book... I'll go back, re-read the crucial dialogue with the speakers swapped, and suddenly everything starts making sense... TT ]

Post reply on HN