Jun 05 2008

java vs scheme

Published by matt at 14:55 under

Last semester, I introduced my students to structured data (including how to traverse self-referential structures), transitioned into classes and objects, and the basics of constructing GUIs in the object-oriented paradigm. A number of them mastered Model-View-Controller in this transition. This isn’t entirely remarkable—it’s actually a simple pattern, when the language itself doesn’t get in the way.

A Java program that produces this:

A GUI in Java

Comes from code that looks like this:

080605-first-gui-java-code.png

Of course, the output from the Scheme version looks the same:

080605-first-gui-scheme.png

But the difference is in the amount of code the student has to write:

080605-first-gui-scheme-code.png

What do I like about this?

  • There’s less preamble (#lang scheme/gui vs multiple imports).
  • The syntax is consistent with what has come before in the student’s experience.
  • There aren’t any mystery calls (frame.pack()?).
  • new is analogous to make-, which students have seen many times before.
  • Callback functions follow naturally from previous work; event handlers are confusing.

I could probably make the list go on and on. At some point, I have to spend more time with JavaME, as it has a much simpler GUI model. And, given that the vast majority of the computers—those would be mobile phones—run JavaME (and not the full Java stack), it would be good to ask around and find out whether we’ll ever see a native version of BlueJ for programming against the ME classes.

Or, it could just be I prefer introducing students to simple languages, and then moving them on to more complex languages as necessary. But this is an old and tired rant, at best.

Trackback URI | Comments RSS

Leave a Reply