Article by Bret Victor, Sept 2012
How do we get people to understand programming? We change it into something understandable.
The environment differs from the language:
The environment allows users to read the vocabulary, follow the flow, see the state, create by reacting, create by abstracting.
The language provides identity and metaphor, decomposition, recomposition, and readability.
“In a modern environment, memorizing the minutia of an API should be as relevant as memorizing times tables.” The environment should show what the code is implying, and map out those arguments on the canvas/window, especially if they are visual in nature.
“In order for a learner to understand what the program is actually doing, the program flow must be made visible and tangible.” For loops are great notationally, but while loops offer more visual order to the process. A visual control for the frame-rate/loop-rate is recommended. A visual representation of how the loop runs is also helpful in recognizing the patterns in algorithms.
“We expect programmers to write code that manipulates variables, without ever seeing the values of those variables. We expect readers to understand code that manipulates variables, without ever seeing the values of the variables. The entire purpose of code is to manipulate data, and we never see the data.” Struggles with state-based functions, such as fill(), are a struggle with not showing the data. If you knew what the default state was, and then how you changed with a function, then you have better understanding of the logical order necessary to execute the program.
Other forms of art and creative expression (painting, music, etc) develop ideas by reacting, not planning. Experimentation and the subsequent evaluation is the key task being performed by creatives. Programming should be no different. A graphics library could, for example, autocomplete shapes with actual sizes. If the programmer deems this the correct shape, they can then adjust the size, dimensions or other arguments. [An environment should “encourage the programmer to explore the available functions. A learner who would never think to try typing the “bezier” function, with its unfamiliar name and eight arguments, can now easily stumble upon it and discover what it’s about.”
Understanding the power of variables and functions can be daunting. An environment that teaches abstraction should start with hard coding, and build up the role of the variable: relating on thing to another. This is still creating-by-reacting, as Victor points out, in that the programmer denotes x as the x-position of both a corner of a rectangle and a triangle as a rule established by the two arguments first being hard coded (and then replaced with the same variable). “The learner always gets the experience of interactively controlling the lower-level details, understanding them, developing trust in them, before handing off that control to an abstraction and moving to a higher level of control.”