Technomancy bus scheme

So during RubyConf, Matz asked how many in the audience had written a Lisp implementation. It was pretty impressive—somewhere between five and ten percent of the crowd raised their hands. Unfortunately I was not one of them, to my great shame.

Anyway, I figured it was about time to fix that. I've been coding up a little interpreter on my bus rides to work. Bus Scheme it is called, and it's implemented in Ruby. (I seriously considered doing it in Emacs Lisp, but I've been writing plenty of that these days, and I actually haven't been touching Ruby a lot.) Anyway, it's a lot of fun. I was thrashing about blindly with the parser for a while, but once I discovered the proper way of separating the parsing step from the tokenizing step (thanks Ryan! I did learn this in school once; I promise...) it all fell into place with a bit of recursion.

 > (+ 2 2)
 4
 > (define fives (quote 5 5))
 5
 5
 > fives
 5
 5
 > (concat "foo" "bar")
 foobar
 

Right now it's just good for simple arithmetic, basic defines, and a few primitives, but I should be getting to lambda next. I think I'll need to read a little further in The Little Schemer before I'm ready to tackle that, though.

Code is up as a tarball. I haven't figured out where to host the git repository yet. I'm really enjoying the exercise and would recommend it to like-minded hackers. Bonus fact: I haven't actually used a real Scheme yet. Everything I know about it I've gathered from reading The Little Schemer, watching the Structure and Interpretation of Computer Programs videos, and reading lots about Common Lisp and Emacs Lisp—all of which I can't recommend highly enough.

In closing: the video of my RubyConf talk has been posted by ConFreaks. Much thanks to them for taping the conference. There are also a ton of other good videos posted there, though not every talk is up yet. Dig in!

« 2007-12-09T07:23:42Z »

Garry2007-12-09T07:59:42Z
That's pretty cool. You can host it at git.caboo.se. Contact me (up_the_irons) in #caboose if you want to go this route.
Garry – 2007-12-09T08:03:07Z
Oh, I see you already have a repo there, good : ) Nice Arthur C. Clarke quote above the circuit boards BTW, it's my favorite.
Ezra2007-12-09T09:25:27Z
That is definitely cool. I'm going to be playing with this. I think it would be fun to implement a scheme that emits rubinius bytecodes and runs on the rubinius vm.
Phil2007-12-10T17:22:53Z
Garry: I might do that. What I meant there is that I'd like to be able to host my own repositories, but that may just be infeasible with my current hosting solution.





Ezra: What a coincidence; you just hired someone who knows a lot about Ruby and has implemented Scheme like five times. I'm sure he could cook up something more appropriate; this is really just a toy for me. Though if you find it useful/fun that's great.
hornbeck2007-12-10T20:23:39Z
Phil,





I wanted you to know that I took your code and built it on rubinius and started adding to it. If you would like me to share what I have or if you have any objections please let me know. I am hornbeck on irc and am normally in #rubinius, #merb, #caboose
Daniel Peckham2007-12-12T22:00:41Z
Hey Phil...I just watched your RubyConf talk. Great job! Good material, and good presentation. The concepts were interesting and helpful, even though I'm not doing as much coding right now.

Name

URL

HTML will be escaped for now. Comments are currently moderated; sorry.