My first seven moths in Zürich have been packed with pleasant surprises. Among them, having the opportunity to meet two developers of two of my favourite lisps: Martin Gasbichler, of scsh’s fame, and Juho Snellman, of sbcl’s. I’ve already enjoyed several pleasant discussions with them (as well as with some co-workers interested in lisp), and it was only natural to go one step further and found the Zürich Scheme/Lisp Users Group.
The zslug will have its inaugural session next Monday 25th, 18:30 at The Lion. Besides beer (the raison d’etre of any users group), Juho will talk about the implementation of sb-cover, a code coverage tool for Common Lisp. If you happen to be in Zürich or whereabouts by then, just come in and join the fun!
Update: The actual address of The Lion is Oetenbachgasse 24. Hope to see you there!
I just spent half an hour watching Martin Fowler’s Introduction to Domain Specific Languages presentation at last year’s JAOO conference (nice name for a conference, i must say). It’s a quite good introductory talk. Fowler acknowledges Lisp’s strength in the DSL camp, takes the opportunity to make fun of it, puts XML closer to where it deserves and does a good job explaining the differences and trade-offs between what he calls internal and external DSLs. For those of you prefering reading to watching, the talk covers the first half of this article.
Fowler likes to call DSL-based programming Language-Oriented programming, and had what looks like an interesting conversation with Neal Ford last August: if you liked the above video, just follow this link. I have not finished watching it yet, but i’ve enjoyed its first 20 minutes. As a teaser, here’s how the talk begins:
Why is there so much XML mixed in with my Java code? Why would not everybody shut up already about Ruby on Rails? It seems like any time you talk to someone about Ruby on Rails they are irrationally exuberant about it and there has got to be some reason for that and why do things like aspects exist? Why do we actually need something like aspects if Java is enough and is there an evolutionary step beyond object-oriented programming? Is the abstraction layer we have been using so far, is that sufficient for the problems that we are trying to solve today and what the heck is language-oriented programming anyway? That is what Martin and I am here to talk about is this idea of language-oriented programming.
A long, long time ago, in what seems now another galaxy, Scheme (in its Guile incarnation) was destined to be Gnome’s extension language. It even featured one of the best window managers i’ve used, until its author disappeared under an apple tree (not that it uses Guile, i know, but it’s extensible using a Lisp dialect too). These Mono days, all those good intentions are forgotten, except for a few fine hackers like Andy Wingo. He’s been putting together an impressive set of Guile bindings for many libraries in the GTK+ and Gnome families and, recently, he’s started documenting them. A first stab is available here. Yeah, Guile is not the nicest Scheme around, nor is Gnome my favorite desktop environment, but still it’s good to see people striving to make our computer world a better place to live. Way to go, Andy!
I finally found time to watch Simon Peyton-Jones’ recent OSCON 2007 tutorial, A Taste of Haskell (split in Part I and II, around 90 minutes each). From the many comments around and a quick look at the slides, I knew it was a basic intro for non-functional programmers and kept wondering if it would be worth the time. From this you can easily infer that either i am a moron or hadn’t seen a talk of Simon’s before. Not that it discards totally the first option, but actually i hadn’t! As it comes out, Simon is a delight to hear and see in action. He’s full of energy and enthusiasm and knows how to transmit his passion for what he does. In this regard, this talk reminds me of Abelson and Sussman’s SICP videos. These guys are not your ivory-tower academic type. They have such a great time doing what they do that they cannot help showing it off. Perhaps it’s because they got their hands dirty implementing the systems they theorize about. At any rate, Simon’s tutorial is absolutely worth watching. If you’re new to Haskell and functional programming, you belong to the perfect audience for this crash course. It is also remarkable that the attendees were quite participative and made lots of questions that made the lecture quite lively. That and Simon’s refreshing sense of humour, which makes these videos great fun even for those of you knowing everything about monads. Enjoy!
I don’t know whether Monty Python ever wrote a gag on programming languages, but if they did, this Erlang video must be it. The funniest thing is that it is pretty serious, and does a great job showing one of my most cherished abilities when using dynamic languages, namely, adding new functionality to a running system on the fly. As for the Monty Python bit, well, you have to see the to know what i mean: i kept laughing out loud during most of its twelve minutes (those Ericsson engineers seem to be taken from The Larch, but then maybe it’s just my sense of humor).
Update: Mike, one of the engineers in the film, has been kind enough to post a comment about the experience, which I’m reproducing here for your convenience:
We gave a well received “demo” in 1990, conjunction with ISS90, a big telecoms conference in Stockholm. We made this movie to record the demo. We actually used a professional company to do the filming, but I won’t mention their names as they would probably sue me for libel.
The worse of it all, is that we were deadly serious at the time. The Monty Python aspect must be due to our backgrounds. Of the people involved, Joe is English, Robert is Swedish - but brought up in Australia, Bjarne is also Swedish but spend some formative years in Scotland and I’m half Welsh half Scottish with some Irish thrown in somewhere.
In 1990, when we made the movie, the very idea of using anything other than C, Plex, assembly language etc to design embedded concurrent systems was heresy, we expected to take the world by storm. It seems that the cheap communication and multi core processors are giving Erlang a boost 16 years later. Well at least in the intervening time we have tested the hell out of Erlang and its implementations!
/mike
PS. If you look carefully at the film, you can see that Erlang at that time had a Prolog like syntax.
PPS. I can’t watch the movie without laughing (at) myself
While we’re at it, let me mention that i like many a thing of Erlang. It’s a curious mix of good stuff: a simple syntax and kind of minimalist flavor that reminds of Scheme, pattern matching and functional variables like Haskell’s, and what amounts to a programming paradigm of its own based on mailboxes and processes (which, as you surely know, are amazingly cheap). Also worth mentioning is Erlang’s error handling philosophy, which is, at first sight, a bit startling (i’m not still sure if it makes perfect sense, but after playing with the language a bit, it looks like it does–this is an interesting post on those matters). Definitely worth a look: see for instance Joe Armstrong’s thesis, or, if you have some bucks to spare, the forthcoming Programming Erlang.
My good friend and Fink packager extraordinaire Aleix has kindly heeded my request for updating Fink’s erlang-otp port to the latest Erlang release: you can find it (with installation instructions) here. It’s working like a charm on my machine. Sweet!
I’ve just seen David Weinberger’s recent Authors@Google talk, a deeply interesting overview of his new book, Everything is Miscellaneous. At first sight, Weinberger’s talk has little to do with programming. He discusses our efforts to classify objects in the world, starting with Aristotelian categories, where there was one and only place for every thing (and, presumably, one thing for every place)–a line of thought rooted on our direct experience with physical objects, culminated with Dewey’s decimal classification system. A line of thought that our modern, digital world has made obsolete. Weinberger is an excellent communicator and makes his points with a fine sense of humour, so, if you have fifty minutes to spare, you can do far worse than pressing the play button below before go on reading why am i mentioning this video in programming musings:
Still with me? Well, the fact is that hearing Weinberger’s thoughts i’ve been remembered of a little exercise i was doing this morning, as part of my recent efforts to finally come to grips with Haskell. You know what? Static typing feels a lot like Aristotelian categorisation: one and only one type for each variable. As is the case with Aristotelian categorisation, there are many situations where a rigid type system works well: we use categories all the time, and they obviously capture part of the structure of the world out there. But they inevitably break down at some point. In my little Haskell exercise (an interpreter for propositional logic), there was a point where it would have been extremely convenient to have more than one type for some of the variables i were using. Maybe it’s just than i’m used to working that way in dynamically typed languages, where the types of the parameters of my functions are in constant flow, and i cherish the ability to widen their domain on the fly.
As mentioned in the talk, Aristotle would be horrified at the prospect of having anything in more than one place of the tree: that would be chaos!. But in our digital world, tagging and mash-ups are arguably revealing themselves as more apt ways to organise our knowledge of the world. There are myriad faces to everything, and allowing different points of view is not only natural, but seemingly useful.
In the same (or, at least, analogous) way, static typing abhors (actually prohibits) variables with mutating types. One has union or algebraic types, that’s true, but one has also the feeling that using too heterogeneous types to construct them is going a bit afield. Could that be as misguided as Aristotelian categories? I don’t know. Building software is so complex that maybe we need the safety net of rigid categorisations. But i’ve noticed repeatedly while programming in, say, Lisp, that using dynamic typing makes things easier in many contexts. The nagging feeling of insecurity i had when i started using Scheme about the lack of type declarations has progressively disappeared, up to the point that languages as beautiful as Haskell can sometimes feel like a straitjacket.
I might be misguided, and perhaps my sense of security is bogus because it derives from very small projects (i have never participated in a large project using a dynamic language), and that liberally bending the type system really leads to chaos in the long run. Maybe the right way to realise this many-facets approach to modeling the world is to put type classes and parametric polymorphism to good use–although even there, i find CLOS generics more natural. But one wonders, could it be that, like our data, the real world problems out there are too complex, too multifarious to fit in a static ontology?
Come to think of it, i’m realising than i’m just badly restating the line of thought people like Alan Kay or Gerry Sussman have been defending for years. Specially their seeking inspiration in biological systems (those complex, messy things so marvelously organised) to model our computing and programming systems. I think that what i’m trying to express (and much, much more) is finely put, for instance, by Alan Kay in his famous talk The Computer Revolution hasn’t happen yet (if you haven’t seen it, please click that play button below) or, more recently by Sussman and Hanson in their paper Building Robust Systems. As i mentioned, in both cases, convincing parallelisms with biological systems are put on the table, and a dynamic outlook to programming systems (including generic functions and MOPs) are favoured. My gut feeling is that these ideas are to programming what Weinberger’s are to data management. I hope that reading and hearing Weinberger, Kay, Sussman and Hanson will convey this feeling better than these somewhat iffy ramblings.
All that said, i still get a kick out of learning Haskell. It must be the Aristotelian in me! Update: Some interesting comments over at reddit.com point out how my analogies could be (and probably are) flawed. In particular, there’s a reference to what looks like a very entertaining book: Practical Foundations of Programming Languages (PDF), which argues exactly the opposite:
This is a working draft of a book on the foundations of programming languages. The central organizing principle of the book is that programming language features may be seen as manifestations of an underlying type structure that governs its syntax and semantics. The emphasis, therefore, is on the concept of type, which codifies and organizes the computational universe in much the same way that the concept of set may be seen as an organizing principle for the mathematical universe. The purpose of this book is to explain this remark.
The University of Pisa is granting to Alan Curtis Kay a Honoris Causa Degree in Informatica for his contributions to the development of the personal computer and of object oriented programming.The ceremony will be held on June 15th, 2007 and it will be webcast live.
This page gives a bit more detail and, most importantly, contains links to the live webcast, which includes a Lection Doctoralis by Alan at 11:30 CET and an interview on the evening where he’ll talk about his recurrent themes (the yet-to-come computer revolution and computer education) and the OLPC project.
(If you read Italian, there’s a page on the motivations for the degree… not that there’s much need of it!)
Recently, someone in the Erlang-questions mailing list wondered about the possibility of writing a Scheme-to-Erlang compiler, possibly inspired on earlier work by Marc Feeley and Martin Larose on Etos, a Erlang-to-Gambit compiler (don’t miss the great article Compiling Erlang to Scheme about Etos’ implementation). Well, Marc has risen to the bait and produced a prototype implementation of Stoe: join the fun and get it here!
Some weeks ago, as a way to give a serious try to the PLT environment, i wrote my first (and only so far) PLT package, MzFAM, a File Alteration Monitor for MzScheme. MzFAM consists of a set of PLT-scheme modules providing utilities to monitor and react to filesystem changes. It exports a high-level interface consisting of monitoring tasks that run as independent threads and invoke callback procedures each time a file alteration is detected. These high-level tasks are implemented using either Linux’s FAM/Gamin monitors or, in systems where it is not available, a pure Scheme fall-back implementation. (A native implementation for BSD systems, based on the kevent/kqueue system calls (see also this nice article to learn more), is on the works.)
As you’ll see in the link above, i took the time to (try to) write a decent user manual, using tex2page (which is included in the PLT distribution, but can be used as a standalone program), a nice tool to write HTML manuals using TeX markup and, if you’re so inclined, embedded Scheme directives.
MzFAM’s implementation served me as an introduction to a couple of wonderful Scheme libraries, both of them authored by Eli Barzilay. In the first place, i needed a foreign function interface to access FAM’s C library. Eli’s FFI is just a piece of beauty: aided by the magic of dlopen and friends, one can access C libraries without writing a single line of C code. See, for instance, this wrapper of the kevent/kqueue system calls, which will hopefully work as a non-trivial example while you read the FFI manual. Will Farr has also put the FFI to pretty good use recently.
MzFAM has to choose at run time among several underlying implementations of the monitoring, and i’ve used generic functions to fulfil this need. No rocket science here: run-of-the-mill polymorphism is enough, but i took the chance to play with the second of Eli’s jewels, namely, his implementation of CLOS for Scheme, Swindle. Now, Scheme object systems are a dime a dozen, and many of them claim some degree of resemblance to CLOS, but Swindle is, by a long stretch, the closest to the real thing i’ve used–why, there’re even some syntactical spots where it is actually nicer than CLOS itself, and is the only (besides Dorai Sitarm’s ScmObj) Scheme object system i know of that provides before/after/around advising. Swindle also comes with a fairly complete MOP implementation, and i’m looking forward to using it after reading Andreas Paepcke’s book on CLOS (which, incidentally, i bought after reading its freely available chapter 3, User-Level Language Crafting: Introducing the CLOS Metaobject Protocol (PS)). All that said, please don’t take MzFAM as a good example of putting CLOS to work: i’m just a beginner.
Finally, let me mention another nice PLT feature i’ve used (although this one is not, as far as i know, an Eli’s hack): the PLaneT Package Repository. Extremely convenient, and a breeze to setup, both from the user’s and the developer’s perspective, and yet another reason for giving PLT a serious try.