Skip to content

Virtually Un-Squeaking: The Paradoxical Link Between Exploring Virtual Worlds, But Studying Haskell and Scheme Instead of Squeak

August 19, 2010

For the past year and a half or so, I have, on and off, attempted to study Squeak in order to learn how to write in Open Cobalt for the eventual purpose of writing my own virtual world, but for some reason, every time that I start to learn Squeak, I have felt vaguely uncomfortable in working in an object-oriented world, and have soon returned to the functional worlds of Haskell and Scheme.

At first, I thought that the reason had to do with my exposure to the functional programming paradigm, and even once made a paradigm shift. However, despite the paradigm shift, I still gradually returned to Haskell and Scheme.

Just now, after watching part of a talk by Rich Hickey, entitled “Clojure for Lisp Programmers Part 1,” I think that I may have discovered at least part of the real reason for this vague preference. During the talk (from 0:18:47 to 0:18:51 on the video), Hickey offhandedly mentioned, “I’m sort of a Common Lisp guy. I’m not a Scheme guy.”

This comment started me on a train of thought about what I felt about the differences in the styles of programming in Common Lisp vs. Scheme, and how these related to the differences between Clojure and Haskell, and eventually to the differences between Squeak and Haskell as well.

Granted, Common Lisp and Scheme have many similarities: They both use S-expressions in their syntax. They are both based on Alonzo Church‘s lambda calculus. They are both ultimately descended from the Lisp programming language invented by John McCarthy in 1958 at MIT. They are both dynamically typed. In addition, they both use lexical scoping for variables.

However, Common Lisp and Scheme are significantly different dialects of Lisp. Firstly, Scheme is a Lisp-1 dialect, whereas Common Lisp is a Lisp-2 dialect. (The difference between the two is that Lisp-1 dialects share a single namespace for functions and values, whereas Lisp-2 dialects have different namespaces for the two. For a technical explanation of this difference, see the paper “Technical Issues of Separation in Function Cells and Value Cells,” by Richard P. Gabriel and Kent M. Pitman, which appeared in the journal Lisp and Symbolic Computation, Volume 1, No. 1, June 1988, on pages 81-101.) Secondly, Scheme supports tail call optimization and first-class continuations and places a relatively heavy emphasis on recursion, whereas Common Lisp supports more special-purpose iterative looping constructs and has more standard common libraries. However, Common Lisp has no way of evolving, whereas Scheme has an RnRS (“Revised^n Report on [the Algorithmic Language] Scheme”) standardization process.

In particular, the emphasis on special-purpose constructs and standard libraries has a tendency to give many books on Common Lisp a more practical flavor, whereas the emphasis on tail call optimization, continuations, and recursion tends to give many texts on Scheme a more academic or theoretical flavor.

One of my mathematics professors in college once said, “Mathematicians don’t care about the real world.” Aside from whether this is true or not, this statement was actually one of my main reasons for switching from disliking mathematics to enjoying it: I myself don’t really care about the real world. When in college, I enjoyed studying algorithms, programming language theory, haiku poetry, and epic poetry, but disliked economics and social sciences. In my spare time, I enjoyed virtual reality environments, fantasy, and science fiction, but disliked business and generally anything related to monotonous social interaction or money. In short, unless a topic was related to some kind of theory, fantasy, or hypothesis, I wasn’t very interested.

This goes back to Haskell vs. Clojure. Being more of a writer than a programmer, I tend to enjoy discussion about programming language theory. While I have participated on both the Clojure Google group and the Haskell-Cafe mailing list, I have noticed that the latter has a much higher proportion of discussion focusing on relatively theoretical topics, such as semantics and category theory. I think that this, rather than differences between the languages per se, is one of the main reasons that I subconsciously prefer discussing Haskell to discussing Clojure.

This, in turn, goes back to Haskell vs. Squeak. Paradoxically, although it is the combination of my interest in experiencing virtual reality environments and the role of Squeak as the basis of such virtual reality development tools as Croquet and Open Cobalt that first brought me to Squeak, it is precisely my interest in the theoretical and fictional which also turns me away from Squeak and toward Haskell. Most of the discussions on the squeak-dev mailing list tend to be of a practical nature, concerning specific issues with using Squeak. However, I tend to be turned off by relatively mundane discussions. I’d much rather discuss, say, the philosophical basis of Squeak in Richard DawkinsThe Selfish Gene than, say, how to get Squeak to output sound. However, such discussions are relatively few and far between in Squeak discussion-land.

On the Haskell-Cafe, however, it is very common to read discussions about why, say, monads are like burritos. Such discussions remind me of finding the result of (cons ‘peanut ‘(butter and jelly)) on page 7 of The Little Schemer. It is common to find discussions of food related to programming language constructs in documents on both Haskell and Scheme. (Virtual) food is fun. Programming by itself can become monotonous after a while, but programming about food helps keep the doldrums away.

Speaking about (virtual) food, time to get a Rolanberry Pie for my avatar. Now if only my avatar could then program in virtual Haskell or virtual Scheme about virtual monad-burritoes and virtual ‘(peanut butter and jelly)….

About these ads
3 Comments
  1. golubovsky permalink

    Well, I am in similar situation: have an ongoing Haskell project (more like server-side), but also need to work on a GUI project for which I chose Squeak. I think, each tool is great for its purpose: being able to manipulate and quickly inspect GUI elements makes buiding user interfaces very fast and convenient in Squeak. I wouldn’t use Squeak for the same purpose I would use Haskell for at “server side”. Perhaps some way of embedding Squeak VM with GHC runtime would make a great copmbination of Haskell solidness in the background, and Squeak flexibility in the foreground. Someone tried this before, piping together Squeak and GHCi (something named Smarty, unfortunately sources seem to be lost). Anyway, good reading (both this, and the referred-to article about studying Squeak).

    • > Perhaps some way of embedding Squeak VM with GHC runtime would make a
      > great copmbination of Haskell solidness in the background, and Squeak
      > flexibility in the foreground. Someone tried this before, piping together Squeak
      > and GHCi (something named Smarty, unfortunately sources seem to be lost).

      That was exactly what I was considering! The main issue with this solution is that it combines Squeak reflection with Haskell referential transparency, whereas the two features are incompatible. Also, Squeak is a purely message-passing programming language, whereas Haskell is a purely functional programming language.

      Do you have a URL for Smarty?

      • golubovsky permalink

        Hi,

        The URL for Smarty (or remains of it) was found on http://www.haskell.org/haskellwiki/Applications_and_libraries/Interfacing_other_languages#Others, and is http://web.archive.org/web/20010306205042/http://www.numeric-quest.com/haskell/smartest.html

        I followed that link; there are partially archived articles on the subject, screenshots are gone, and no link to anything downloadable.

        I see 2 practical ways to couple Haskell and Squeak.

        1: Smarty (piping) way: run GHCi via pipe, send commands down the pipe, parse results. You likely will be able to build a multi-column widget (like System Browser) by querying loaded modules, function info, etc. Making GHCi steer Squeak to manipulate the screen may be harder; you need to have some Haskell code which outputs Smalltalk statements, and interpret them in Squeak as they arrive.

        2: Squeak on Android (embedding) way. Use a modified Squeak VM (event-driven) to be embedded in Haskell program; this makes steering a bit easier logically, but needs more programming at VM plugins level. You also likely need a way to draw Squeak objects on e. g. OpenGL surface as embedded VM does not have any IO on its own. Android implementation just simulates a framebuffer in the memory which is given to Java code via JNI, and is updated on the screen as needed. Slow, but works.

        See http://code.google.com/p/squeakvm-tablet/wiki/PresentationNotes.

        Neither of these ways is trivial at all. But results may be promising. I was going to try the second way (as I have some experience with embedding Squeak) once I can find time.

        Regarding ref. transparency: Squeak may be viewed as another graphics library, like GTK or Wx, so no big difference. VM heap memory is just that, external mutable chunk of memory, and should be accessed via IO monad, in case you want to explore Squeak objects from Haskell code.

        Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: