News for hackers. Stuff that matters.
Re:Turning off syntax highlighting by jowiar on Sunday November 06, 2016 @01:52PM (#12886455)
I think a large part of the issue with syntax highlighting is that our "standard" for syntax highlighting is rather dumb. A few thoughts:

- Who the hell would write prose by making all the verbs blue, the nouns red, and the adverbs green (or something to that effect). That's what we do for code. Something togglable a-la iA Writer might make sense, though. At the same time, I can sort of understand, though, because we're almost always in "edit" mode for code, very rarely in pure "write".

- I find having lint-errors highlighted provides a similar nudge to the "squiggly-red underline spellcheck".

- Our editors aren't configurable enough with regards to typography. I like to use subtle weight changes, highlighting "headings" and whatnot, and very few tools seem to make that change available.

- Semantic highlighting seems super interesting, but I haven't found a tool that I like yet.

One project I'd love to see is to get a bunch of folks together to do some proper layout-by-hand on code -- Given 100% control over typography, how would you format it to maximize readability, minimize distraction, highlight relevant contextual knowledge, etc? And then work to push tools in a direction that they support configuration to allow for said tasks.

Re:Turning off syntax highlighting by jmhain on Sunday November 06, 2016 @01:58PM (#12886483)
> Who the hell would write prose by making all the verbs blue, the nouns red, and the adverbs green (or something to that effect).

Slightly off topic, but I think doing this could actually be useful for learning languages, especially highly inflected ones (if you extend the color coding to account for gender, case, etc.).

Re:Turning off syntax highlighting by raattgift on Monday November 07, 2016 @06:39AM (#12890332)
The farm was used to produce produce.

He could lead if he would get the lead out.

A bass was painted on the head of a bass drum.

That that that that boy said is not that that that that boy said.

Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.

Re:Turning off syntax highlighting by Blaque on Monday November 07, 2016 @06:00AM (#12890169)
That's what I remember doing in primary school when we were learning french grammar, and later with ESL. Is this not a common teaching tool in other languages/school systems ?
Re:Turning off syntax highlighting by braythwayt on Sunday November 06, 2016 @02:21PM (#12886579)
Speakers use inflection to emphasize the important things in the message. In a single method, there might be a few lines of assignments and setup, a few lines to actually do what needs to be done, and then some formatting of a return value in the correct structure.

Maybe what we want to do is emphasize the few lines that matter the most. Right now, we try to break the methods down into smaller and smaller pieces, resulting in the “In Smalltalk, everything happens somewhere else” syndrome.

Re:Turning off syntax highlighting by markbao on Sunday November 06, 2016 @02:00PM (#12886486)
I'm not sure I entirely agree with you on your first point. Writing isn't like code in that code is like a complete system of logic. I think having ways to show how that logic is organized, using positioning (whitespace) and coloring of logical operators is a pretty useful addition, whereas highlighting parts of speech (which don't express a logical structure) isn't that useful.
Re:Turning off syntax highlighting by qznc on Sunday November 06, 2016 @02:41PM (#12886686)
Yes, nice idea. For example, it might be helpful to have different colors for local variables, global variables and fields. If you accidentally shadow a variable, you might notice this way.

Likewise, highlight macros in C and make them different to variables/functions.

Re:Turning off syntax highlighting by marmaduke on Sunday November 06, 2016 @04:15PM (#12887075)
IntelliJ & MATLAB both change highlighting to indicate variable scoping etc, so it's neither unseen nor impossible, just uncommon in simpler editors.
Re:Turning off syntax highlighting by amk_ on Sunday November 06, 2016 @04:34PM (#12887168)
More advanced tokenizers are able to emit different tokens for those scopes, but not all syntax highlighters differentiate between them. The online Textmate theme editor is a good place to examine what's availabe because many text editors are able to import .tmThemes or use them directly (Sublime, VS Code).

You can see here that the Monokai theme supports about 20 tokens and doesn't differentiate much between scopes: https://tmtheme-editor.herokuapp.com/#!/editor/theme/Monokai

Personally, I prefer highlighters that do something to highlight variables differently, like this variant of Monokai (ie around line 45 for the JS example): https://tmtheme-editor.herokuapp.com/#!/editor/theme/Monokai...

Re:Turning off syntax highlighting by Adverblessly on Sunday November 06, 2016 @03:05PM (#12886789)
EDIT: Actually, I think I misunderstood what you meant.

What you are describing sounds like regular syntax highlighting to me. This is my current theme: http://imgur.com/a/cQbWL You can see the level of customization available fits with what you described.

And it has really helped many times in the past, preventing all sorts of silly mistakes that could have been hell to debug. Like shadowing a variable :)

Re:Turning off syntax highlighting by cygned on Sunday November 06, 2016 @02:54PM (#12886742)
Re:Turning off syntax highlighting by qznc on Sunday November 06, 2016 @03:01PM (#12886771)
From reading the README, it just cycles through colors. The colors are random, not semantic, so the name seems to be misleading?
Re:Turning off syntax highlighting by cygned on Sunday November 06, 2016 @03:08PM (#12886806)
Haven't tried it yet, just bookmarked it. So I can't review it.
Re:Turning off syntax highlighting by hvidgaard on Monday November 07, 2016 @02:47AM (#12889534)
There is a lot of things we can do with highlighting, but that is not one that we should. An online linting tool should tell you that a variable is shadowing another (and I personally believe that it should not be possible at all). If you make a syntax highlighter that can color differently based on scope, you're only one stop away from a tool that can warn you about shadowing anyway.
Re:Turning off syntax highlighting by yoz-y on Sunday November 06, 2016 @08:17PM (#12888140)
Many IDEs do that. For C++ i use Qt Creator which differentiates all of that and more (virtual functions, globals, primitive vs complex types etc)
Re:Turning off syntax highlighting by wanderingstan on Monday November 07, 2016 @10:44AM (#12891905)
> One project I'd love to see is to get a bunch of folks together to do some proper layout-by-hand on code -- Given 100% control over typography, how would you format it to maximize readability, minimize distraction, highlight relevant contextual knowledge, etc? And then work to push tools in a direction that they support configuration to allow for said tasks.

I've had a similar thought for several years now. Want to hash out some ideas? You can contact at my site wanderingstan.com or on twitter @wanderingstan.

Re:Turning off syntax highlighting by abecedarius on Sunday November 06, 2016 @07:36PM (#12887988)
> Given 100% control over typography, how would you format [code] to maximize readability

There was a book on this, whose title I'm blanking on. Anyone remember? Color wasn't an element, since it was an older book focusing on printing on paper.

Re:Turning off syntax highlighting by pYQAJ6Zm on Monday November 07, 2016 @06:08AM (#12890201)
Kinda rings a bell for me, although not from a book, but some LaTeX manual. Maybe this helps: http://tug.ctan.org/macros/latex/contrib/algorithm2e/doc/alg...
Re:Turning off syntax highlighting by abecedarius on Monday November 07, 2016 @09:13PM (#12897051)
That wasn't it, though that looks relevant for anyone thinking of working on this problem. Thanks for the pointer.
Re:Turning off syntax highlighting by marxidad on Sunday November 06, 2016 @09:24PM (#12888362)
Bjarne Stroustrup's C++ book used a proportional font with tabular spacing.
Re:Turning off syntax highlighting by abecedarius on Monday November 07, 2016 @09:15PM (#12897053)
So did the book I was thinking of, but it tried more fancier stuff too and iirc reported on some experiments in code reading.