After reading Bret Victor’s new essay [Learnable Programming](http://worrydream.com/LearnableProgramming/) and [some](http://nothings.org/computer/victory.html) [of](http://aleffert.livejournal.com/132353.html) the [responses](http://news.ycombinator.com/item?id=4577133), the idea keep lingering in my head.
While his famous lecture [Inventing on Principle](https://vimeo.com/36579366) tackled the idea of making new principles, people are mostly interested in applying that visualization method on [IDEs](http://www.chris-granger.com/2012/04/12/light-table—a-new-ide-concept/) and [such](http://www.khanacademy.org/cs). Although most of these efforts are largely experimental, I still find it harsh to dismiss them and consider them as a failure. Live coding is not the point of Victor’s lecture or essay, but it is still _immensely better_ than a dumb editor and cold console that I used to use to learn programming.
(My girlfriend, who majored in landscape design, learned most JavaScript concepts with the rudimentary web editor from [Codecademy](http://www.codecademy.com/). She found it engaging and helpful. I doubt she will find it that way if she was given a Unix console and gcc, checking `a.out` output every time a change was made.)
In the area of learning a new way of thinking, things as simple as live coding can be useful.
What’s more important is how do we progress after grasping basic concepts like iteration and function? While most people think learning programming as a one time effort, I have programmed for more than 10 years and I’m still _constantly learning_.
Malcolm Gladwell’s [Outliers](http://en.wikipedia.org/wiki/Outliers_(book)) brought us the concept of 10,000 hours of practice. He told us that Bill Joy became a master after practicing programming for 10,000 hours. But what exactly has Bill Joy done in his practice is unknown to us. We all knew that Bill has coded the vi editor and some of the BSD network stack. Did he start practicing from writing a smaller subset of vi or BSD?
The essential question here is how do we learn higher levels of abstraction and design systems more complicated.
First, I personally believe that **we need to understand the details to do higher level designs**. You won’t be able to design an efficient system _without_ knowing the **implementation costs** and **performance impact** of critical code paths. That’s why I usually choose to dive to the bottom and solve/evaluate a few critical issues before looking at the big picture.
However, human mind is not a precise machine that can assemble low level details into high level constructs. After mastering the details sometimes we need to take it away, clear our minds to see a bigger picture, otherwise our heads will be occupied by low level details and have no time to abstract. Contradicted as it is, *visualization* becomes a really useful tool to _hide_ the details for us.
With visualization as simple as a pie chart, we will suddenly able to free our minds, stand on our previous results and reach higher fruits. That, I think, is the real value of Bret Victor’s idea. What I disagree with him is that his idea doesn’t have to be a groundbreaking rule to revolutionize our ways of programming, the existing tools and IDEs can still equip that as a weapon, to help us tackle even more complex problems.
Imagine code visualization as an **amplifier**. Without that it is possible to work on certain issues, but with that you are suddenly able to work on harder issues in a more efficient manner.
How to make that really work? Let’s start from small. Take your favorite IDE for example, Xcode can have built-in visualizer for native Cocoa classes such as `NSString`, `NSArray`, `NSColor` and `NSFont`. The code to show them is already there, just need to find a way to present. Qt Creator can have visualizer for `QString`, `QTransform`, `QColor` and `QFont`, etc.
For visualizing the states of a program, it works just like our existing debugger with variable watching feature. Except that is presented in a _structural_ way, specific presentation can be given by the programmer himself, just like writing a test case. We can have a drag-and-drop layout interface to do that.
Some of Bret Victor’s ideas (like parameter tagging) can already be achieved with a static analyzer such as clang. Others can only be done in execution. How to speed up execution to avoid setting up a lot of states is the most interesting problem. I think we can try to reduce the amount of input and take an independent block of code (functions without side effects) for examination in an _isolated_ sandbox environment, supplying the required parameters in a simpler way just like preparing for test data sets.
In summary, I still expect that this visualization tool as a _programming assistant_. An assistant that can take a piece of code, walk through its execution and explain it to me how it works. Even if can only tell how does _one_ variable transits in a loop, it will still be much better than me evaluating it by hand with paper and pencil. In short, hand the repeating tasks over to your machine and focus on something more **creative**, that’s what we humans are good at.