Wednesday, February 01, 2006

Processing Notes, 25 January 2006

I am a lecturer on an MSc course at the Bartlett in UCL, and one of my friends Tom suggested I keep a log of particular difficulties in teaching architects and designers to program via the Processing platform. Thus disclaimed are my digressions from rare postings on chefery, politics and Potter.

Divuldging my side of the fence: I feel Procesing is a deeply flawed albeit contagious and buzzy platform for teaching programming. My criticisms are plenty but now public — because "in the trenches" teacher and student would benefit from these gripes being addressed. It behooves the whole community if nascent programmers come away from their terms spent in Processing with academe nostalgia, not flight. Their appraisals at future design and architecture gigs will make or break Processing, either promoting or dashing its current momentum.

And so, my notes from last week's lecture on boids:

Algol to C to Java to Processing: Matching curly braces — or begin/end blocks — is a necessary evil in this lineage of programming languages. Processing helps by highlighting a matching brace while hovering, but this is of limited use to students who are learning by cut 'n paste. A more helpful feature would be an "auto format" option to indent and align a tab of Processing code, especially after said code has been mangled by many-a CTRL-V. Check, thanks Tom.

No argument methods and functions: Other 4GL languages skip the irritating verbosity of parentheses when passing no arguments, so why shouldn't Processing? Think "obj.meth;" instead of "obj.meth();". Like many of my criticisms, this may seem pedantic nit-picking of the Java legacy. However these sort of redundant redundancies just devastate novices.

Stack traces: Processing should move my cursor to the correct tab and line of a particular stack trace. There seems to be a deemphasis in Processing on making stack traces visible, but they are actually a very natural and linear way to review a program's logic in hindsight. At the bare minimum, Processing's stack traces should at least list line numbers and tabs.

float vs. int: Now we come to probably the most consistently baffling and frustrating (to both teacher and student) aspect of learning to program with Processing. The distinction between floating point numbers and integers, and the accompanying nasty casting, is fundamentally non-intuitive. This is the 21st century; memory, disk and CPU are cheap. Have the stones to make everything arbitrary-precisioned floating point numbers. All literals and all numeric variables are this "super float," and let the interpreter or compiler worry about the optimizations of when-and-where a value can be coerced for faster integer math. From the learning programmer's perspective, it is almost maddening that "1.0/99 != 1/99". And in light of Processing's already compromised performance, please ignore anyone saying "but it'll be slow."

Not criticisms of Processing specifically, but general practices to remember when teaching designers and architects to program:

Top down: Professional developers grow accustomed to a progressive focus on the minutiae of a problem, while gluing these pieces together "later." Long experience in writing software, or a background in mathematics, facilitates this minutiae-driven programming process. Though you may know this bit of code will be needed eventually, it is more conducive to teaching good programming style — or to teaching programming at all — to work from the top down.

Even if it does not resemble your actual programming practice, live lecture or lab demonstrations of coding should invert the minutiae thinking: Code and discuss the most general logic of the program first, and fill in the blanks later. One of my first programming teachers taught programming in this style, and while demanding of the lecturer, it is deeply instructive to code the skeleton first.

Vector vs. points data representation: While we're used to modeling a velocity vector and a spatial position with the same underlying data structure, this is a significant leap for students getting used to 3D programming. This is true even for those designers and architects comfortable with a CAD package. Drill this "not distinction."

Heap data is sorta global: Yet another murky legacy of Algol-ish, side-effect-ridden languages is the confusing heap; that an object instantiated in a small method, but referenced via a stack variable that is eventually returned, is visible to the caller — another conceptual leap for novice programmers. A visual diagram of a simplified heap can help. A purely functional language for learning would help even more...

While these feature requests are certainly not on the grand scale of software methodology practics, these sorts of "little things" are what enable frequent and vicious refactoring, a vital practice in good top-down object oriented (OO) development.

1 Comments:

At 2:29 PM, Blogger Tom Carden said...

Glad you took the time to do this. Herewith a defensive first pass reply...

Processing has "auto-format" in one of its menus. Really.

I like () for no-arg functions since it means I can tell the difference between a method/function and a variable - for instance:

thing.doSomething(otherThing.gizmo); vs thing.doSomething(otherThing.gizmo());

In the former if I know what gizmo is I can get on with my day. In the latter I need to know what gizmo calculates before I can get on with my day.

It sounds like you're saying Processing's handling of stack traces is a bit buggy? http://dev.processing.org has the bugzilla. If you're not saying that, I'm not sure what you mean.

float vs int - interesting idea, but includes an unwarranted assertion about "compromised performance". In comparison to what, exactly? And how easy is that to teach to designers and architects?

Then you say "Not criticisms of Processing specifically, but general practices to remember when teaching designers and architects to program:". That's a great disclaimer, but it's best moved to the top of the whole article as far as I'm concerned. At least one point higher, anyway.

Top down - I think I get what you're getting at here...
of course your prototypical Processing program of course can be quickly sketched out as a skeleton - setup/loop/mousePressed/keyPressed functions etc. I'm often tempted to write a macro to add them all in for me (and toxi's jedit shorthand takes that to the nth degree).

vector vs points ... javax.vecmath subclasses Point3f and Vector3f from Tuple3f, so that both can be used to modify each other. when you say "drill this "not distinction"" do you mean to make sure that people understand that a point in space can be represented by a vector from the origin to that point, so the same data structure can be used?

heap vs stack stuff - yeah that certainly sounds like a tough one, if you make the distinction between stack and heap at all. Does it help to talk about memory and scope instead?

 

Post a Comment

<< Home