Sunday, April 26, 2009

My First Impressions of Smalltalk

As a disclaimer, I've only been using (Squeak) Smalltalk for a couple weeks, and haven't written anything major in it yet, so this is currently just my first impressions. But wow, what a first impression. The "turtles all the way down" object model is absolutely delightful to work with, and having the whole development environment so tightly linked is incredible. It's like going from a complied-only language to a language with a REPL and realizing how clunky and slow your development flow used to be: Having not just a repl, but a whole organic environment that you can play with and introspect into...The analogy that came to mind was that the difference between programming in Smalltalk and other programming in languages is like the difference between building a bridge and gardening.

I had briefly tried mucking about with Smalltalk previously, but my Emacs-centricism made me avoid Squeak in favour of GNU Smalltalk which, while doubtless a fine implementation, did not really demonstrate to me the joy of Smalltalk the same way Squeak does. Now that I've started to use Squeak a little more (went through "Squeak By Example", now in the process of trying to write some Seaside stuff), I'm starting to understand why Smalltalk is held up there with Lisp in terms of languages that smart people like.

For me, the hard part about learning Smalltalk was wrapping my brain around the idea of your all your code being in an image, as a series of living objects, rather than existing only in flat text files which are briefly given life when run, then filt out of existence. It was initially kind of hard to accept what seemed a disgusting loss of control: I want to be able to have all my code in front of me dammit, not scattered to the winds, where I have to use some kind of GUI Browser (gross!) to see my code, and even then only being able to look at one object or method at a time! I think I've come to realize, however, that this paradigm has definite advantages. For one, being physically unable to view massive blocks of code all at once forces you to write well-factored, conceptually-separated code right from the get-go.

I haven't had the chance to make anything real yet in Smalltalk, I'm thinking of starting to write some webapps using Seaside, which seems quite enjoyable...Smalltalk seems well on it's way to becoming one of my favourite languages—While I've been a Smug Lisp Weenie since high school, I think I may very well soon become a Smug Smalltalk Weenie :)

Lisp, According to Me

Many other people have talked about Lisp at far greater length and in far more depth than I can. I therefore begin by assuming the reader has at least passing familiarity with Lisp and the oceans of ink spilled in its name.

My Road to Lisp

I started learning Lisp in high school, with (Gambit) Scheme, after being inspired by Steve Yegge's Tour de babel. I read On Lisp and wrote reams of Scheme to implement all sorts of fun things (looking through my old stuff, it seems I managed to generate more than 7 kLOC of Scheme during grade 12). Eventually, however, I realized that I was merely writing libraries, and not actually doing anything with them. This, along with a certain sense of curiosity, led to me taking up Common Lisp.

While I appreciate the conceptual purity of Scheme, I also find complex, powerful systems to be deeply intriguing (more on this in my upcoming post on Perl), so I immediately fell in love with CL. The sheer number of things you can do with it, even beyond macros...CLOS (probably my favourite object system), its unique (AFAIK, but I'm sure I'll be corrected if mistaken) and incredibly system of restarts and exceptions, ASDF, optional type tags...I could go on for ages. As Steve Yegge put it (albeit in a manner not meant to be flattering to CL):

  • Scheme is an exotic sports car. Fast. Manual transmission. No radio.
  • Common Lisp is Howl's Moving Castle.
While it's true that Common Lisp may not be exactly elegant...which would you rather have, a sports car, or a gigantic, semi-sentient, ambulatory castle with magic powers? I rest my case.

I have used Clojure a little bit, but mostly as a means of learning my way around Java without actually having to learn Java. Quite pleasant, and very nice to see a Lisp dialect that doesn't shackle itself to the legacy of the crufty CL standard, nor to the extreme minimalism of Scheme.

That being said, my language of choice eventually shifted from (Common) Lisp to Factor. I found that pretty much anything I could do in CL I could do at least as easily in Factor, but in a much cleaner manner, in a much more tightly-knit community, and crucially, I could see the evolution of the language over time: Unlike Common Lisp, which has been basically unchanged for longer than I've been alive, Factor is still growing and evolving, and knowing I can (and have, in some small way, I may flatter myself to think) help shape the future direction of the language is a powerful incentive.

Well, that went off on a bit of a tangent (mayhaps I should do an entry of Factor?), so let me try to summarize my attitude towards Lisp. While I was once convinced that Lisp was the language, more experience with other languages has led me to begin to question that. It is indeed a very enjoyable language to program in, and macros are certainly the cat's pajama's, but I'm not sure if it's really that much better than some of the interesting newer languages on the scene, such as Haskell, Factor, et cetera. So...a very nice language, one that I had a long infatuation with, but not necessarily the end-all be-all of languages.

Saturday, April 25, 2009

Been a While...

Well, it's been ages since I wrote anything here, as school as been consuming my life...but summer is nearly here, so hopefully I'll be able to start writing again. In the meantime, a brief summary of what I've been up to:
  • I've been doing a bit of factor stuff on the side, but nothing worth contributing.
  • I wrote about 5 kLOC of PIC assembler for a school project, to control a "robot". Not the most pleasant experience.
  • I started playing with perl's Catalyst, and found it to be pretty nice...more grokkable than RoR, for me at least.
  • Just started trying to learn Squeak Smalltalk, which is quite a beauty thus far.
Not much, other than that...second-year engsci barely gives one time to sleep, much less have fun. I have been considering taking advice I was given concerning this blog and starting to write about various other topics, besides programming. I think I may enjoy that..


I take a great deal of pride in knowing a large number of programming, in order to give myself more motivation to write, I'm going to soon be starting an n-part series of my impressions, opinions, and snarky comments about as many different languages as I can. Should be fun!