Does syntax highlighting help programming novices? (2018)
dl.acm.org
dl.acm.org
Keep in mind, I’m no novice. So, my opinion is absolutely unrelated to the article… so it is on HN.
It’s also a crude spell checker. “Hmm, the word didn’t change color so it’s probably not `elseif` … let me try `elif`. Yep, that changed color!” Kind of thing.
The other two major pain points where color coding really makes it obvious what’s going on, is when a string is left unclosed and everything turns into “the wrong” color and matching of parentheses.
Say what? As in the color channel may be useful in program comprehension, but wasted on lexical syntax? ... And we can tell from studying novices?
More like: opportunity to study syntax coloring was squandered on novices that don't actually understand the programming language.
Do other industries do this? In construction, do they test the effectiveness of a laser level by studying apprentices?
You can look into building a tool that can extract all or at least part of that dataflow graph for you by analyzing the AST. There are different approaches to this, some being more imperative (write a program to implement a chaotic iteration algorithm which builds the graph) and some being more declarative (extract facts about the code and feed them to a Datalog engine alongside a DL program describing the relations required to build the graph, or utilize something like CodeQL which already has the functionality available.)
- - -
To clarify, I don't mean generating a visual version, but to instead highlight structure (e.g. background color for a for-loop and its indent), not keywords
Take SQL for instance: we already have tools that will take table definitions and built an UML tree from that. I used that kind of tools 3 times in my life, and threw away the result to draw something manually to really understand what was happening. The main issues were excessive visual complexity, noise from all the meaningless bindings, random component placement making is hard to mentally group components.
I’d expect these issues to be 100x worse with any code that expands beyond a single function, as the cyclomatic complexity would in average be a lot higher and we’d have a lot more noise from guard conditions and boilerplate.
Looking at it the other way works too: coding what we write everyday in ruby or typescript, but in Scratch, would be a crazy visual mess that would push anyone into depression.
My human brain is very fast at parsing that to a tree based on visual cues, while the program does the same constantly - syntax highlighting is important exactly for this reason, if it is colorful, it parsed correctly, that’s the feedback between machine and human.
Even manipulations are AST-level, I expand the selection based on that, etc. It just has a very fast, “invisible” node-edit mode where you can just type a few characters to change the function node’s name.
My ideal situation is to have a language that Jetbrains tools understand, because I also learn things by just having the IDE extracting a variable or a function, I can understand some weird variable or type things by the way they typed the extraction.
If you can suffer that long without switching back prematurely, maybe you're built different, and that's good for you, but noone I know could last that long.
Looking quickly at an expression or block and visually seeing where the matching braces/parentheses are is a huge time saver for me.
Believe me. I have programmed by writing code in plain text editors (vi / notepad) and compiling them on the command line and using a line editor to fix issues. I have also used IDEs and have come to appreciate the productivity gain afforded by syntax highlighting.
I like VisualStudio / VSCode but one recent issue I have had is with their parentheses/brackets/braces coloring. It doesn't add a lot of value as I am used to matching parantheses/brackets/braces using the hotkey. I find it annoying and distracting enough, but haven't bothered to research if that option can be turned off in the IDE.
Syntax highlighting is very helpful if you are a polyglot programmer.
Look into the setting '"editor.bracketPairColorization.enabled": true'.
Bret Victor - The Future of Programming
Programming could have been be something completely different.
Uhh, as someone who likes learning languages, this is immensely helpful.
One of my favourite Mandarin graded readers actually highlights personal pronouns in the text, (because names are just Chinese words) so we can read the story without getting caught up in "the car climbed the tree? Wtf? Oh no it's 'the guy named car' has climbed the tree"
That being said I agree that this is a digression, I think syntax highlighting will only help newbies marginally. There's a lot more that goes with understanding code
I haven’t really thought it through, but maybe the idea sparks somebody’s imagination out there.