A Web Of Scheme

2010-11-26 12:39 +0000

I'd like to start this blog with the documentation of my attempt to revive a website that I started in 2003 or so. It was a small community-like site with a focus on literature. People could sign up, publish their poems and stories as well as comment on those of others. Thinking about it now, it was pretty Web 2.0 for its time. Or maybe it's just an example of how vague that term is defined. Anyhow, back then not knowing any better I wrote it in PHP and in a true PHP manner used MySQL as the data storage. It got fairly popular but a few years later (I think in 2006) I shut it down because I didn't want to maintain PHP code anymore. If you are wondering why: The reason is not that PHP didn't offer full Java'esque OO support, yet (or did it?). You may want to check out this informative site to get an idea.

Off The Rails

In early 2008 I started a rewrite based on Ruby on Rails but I never finished it. Since then I have grown rather tired of Ruby, particularly Rails.

I was a (relatively) early Rails adopter (starting with version 1.0-something) and quite enthusiastic about the things it offered. Through Ruby I learned a lot about simplicity, clarity and elegance. It was also the first time for me to encounter concepts of functional programming. The whole experience was an overall eye-opener, really.

However, the longer I worked with Ruby, the more I learned about its problems and dusty corners. These are easy to ignore for a while but after I got bitten a few times too often (this might be up for a post of its own in the future), I started looking for alternatives. I wanted something conceptually clean, flexible and beautiful, something that would bring back the wonder and enthusiasm I felt when coming from PHP, Java and C# to Ruby. I started playing with Io, learned about Smalltalk, and dived into JavaScript for a while. The more I worked with those and similar languages, the more it occured to me that they all claimed or were alleged to borrow core ideas from Lisp. That got me interested: What was it about Lisp that inspired all these interesting languages? Why not find it out myself?

Open Parenthesis

The Lisp world is a different world. Compared to other programming languages it is ancient and may be the oldest one that is still in use and development today. You can witness that legacy in many aspects: There are things in the language itself which are historical coincidences that turned into traditions over time (like the representation of lists as so called cons cells, the names car and cdr etc.). There is an academic community that has produced and is still producing papers about every detail of Lisp that you can imagine. There are dozens of dialects and hundreds of implementations. It has a vital and engaged community of hackers around the globe who work with and on Lisp every day -- even if you leave out the Elisp guys. But it largely remains terra incognita to the broad public which only has a vague idea that Ruby and Python somehow took some strange ideas of Lisp, removed the parentheses and turned them into a Serious Language™. One obvious reason for that is the Lisp community's general disregard of marketing measures whatsoever. Just take a look at some implementations' websites and you'll know what I mean. This may very well be a result of Lisp's roots in academia. I have a feeling that this is going to change in the near future with the advent of Clojure and its (albeit marginal) mainstream exposure. If Java people know a thing about something, it's marketing.

The situation is improving though. Barski's recently released Land of Lisp takes up the spirit of Why's (Poignant) Guide to Ruby¹, Seibel's Practical Common Lisp attracts many newcomers and classics like Abelson's and Sussman's Structure and Interpretation of Computer Programs are still (or again?) regarded as must-reads, even by this guy.

Into The Coop

After spending a bit of time with Common Lisp, I quickly realized that Scheme is actually closer to what I was looking for. I fiddled with Gambit for a moment because I was interested in (the probably dead by now) Minno project but quickly got deterred by Gambit's lack of library infrastructure. With regard to availability of libraries, Racket (back then still called PLT Scheme) would have been the obvious choice but somehow it didn't click with me. I finally settled for Chicken Scheme since it seemed to offer lots of existing libraries, was under active development and, probably most importantly, had a friendly and smart community which I am very glad to be a member of today. If you'd like to get an idea of it, check out the weekly Chicken Gazette or drop by in #chicken on Freenode IRC.

I have been using Chicken as my day-to-day utility language, my calculator and my environment for experiments for about a year now. This has been a very smooth and enjoyable ride so far but fully replacing Ruby also means replacing Rails. I felt I needed a few more things before I could actually write a web application in Chicken though. Don't get me wrong, it has many excellent web development related eggs (that is, of course, what Chicken extensions are called) already: There is the great webserver Spiffy built on the HTTP library intarweb, there is SXML, and excellent bindings for both PostgreSQL and SQLite. I wasn't really aiming for a web framework like Awful (which is cool in its own right). I wanted some components I could combine flexibly to build web applications in a way I feel comfortable with while avoiding to lock myself too much to one specific pattern.

For example, I like the RESTful resource centered approach Rails introduced in 2.0 but it didn't really follow through. This made it painful when your application didn't exactly fit the Rails Way. Unfortunately, this has not substantially improved even in version 3.0, although other things certainly have (I might cover this in more detail in another future post). So I wanted something similar but better for Chicken. However, before rushing into an API that does a few things good but isn't easily bent for special purposes (most Clojure web components give this impression) I started with a very basic URI matching and dispatching library. I hope to be able to layer a higher-level API on top of that without losing the full flexibility of the lower layer. This is something most Scheme libraries do really well. Maybe it's a result of the language's deeply ingrained Higher Order Function programming style.

Long story short: Now that I have invested some effort in creating a few web development libraries for Chicken, I will try to re-build the site once again. It is my plan to turn that process into a series of articles displaying what problems I encounter, what ideas I consider and what things work well. One of my aims is to show that lispy languages lend themselves very well for real-world applications. I'd also like to demonstrate how Chicken with its numerous eggs is a good candidate implementation for such efforts. Be my guests!


1
Ironically, Why The Lucky Stiff and Zed Shaw are two of the persons I regarded as the most inspiring and shining representatives of the Ruby community -- meanwhile, both of them have left that ship.