5 ms·
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
by jowiar 10y ago
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.
- abecedarius 10y ago> 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.
- marxidad 10y agoBjarne Stroustrup's C++ book used a proportional font with tabular spacing.
- abecedarius 10y agoSo did the book I was thinking of, but it tried more fancier stuff too and iirc reported on some experiments in code reading.
- pYQAJ6Zm 10y agoKinda 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/algorithm2e.pdf http://tug.ctan.org/macros/latex/contrib/algorithm2e/doc/alg...
- abecedarius 10y agoThat wasn't it, though that looks relevant for anyone thinking of working on this problem. Thanks for the pointer.
- jmhain 10y ago> 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.).
- Blaque 10y agoThat'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 ?
- raattgift 10y agoThe 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.
- markbao 10y agoI'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.
- braythwayt 10y agoSpeakers 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.
- qznc 10y agoYes, 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.
- cygned 10y agoSomething like this? https://github.com/jaxbot/semantic-highlight.vim https://github.com/jaxbot/semantic-highlight.vim
- Adverblessly 10y agoEDIT: 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 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 :)
- marmaduke 10y agoIntelliJ & MATLAB both change highlighting to indicate variable scoping etc, so it's neither unseen nor impossible, just uncommon in simpler editors.
- amk_ 10y agoMore 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 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%20Extended%20Mod https://tmtheme-editor.herokuapp.com/#!/editor/theme/Monokai...
- wanderingstan 10y ago> 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.