Dada
|> Structures
|> Algorithms

Reflections on Writing an Elevator Simulator in Scheme

I learned a lot more about scheme and its tools

This is another reflection on working with Scheme. I previously wrote one on writing a slot machine in scheme. This time I tried to write an elevator simulation game. Here is what I learned.

  • Using emacs to develop in scheme
  • Using the repl
  • Debugging in scheme
  • Jumping around different scheme implementations, like chez scheme and racket
  • More practice writing my own functions when some of them were missing
  • Using r7rs's pdf as a reference while working
  • Using html canvas

The month-long project was my February entry for the "One game a month challenge.". The initial vision was creating a builiding business simulator game with income, competition, and music. At the end, it ended up as a simple animated demo.

Why the downgrade? I ran out of time. Due to starting with a complicated idea that took me three weeks to build before I could test at all. When I wrote the slot machine, I started with a line giving me a random number. I then built it up from there. In contrast, the simulator took me three weeks to get to the point where I could debug. Once there, debugging was taking a long time. So at mid-month, I deleted everything and started over again, this time being deliberately simple. I was able to finish an animated demo in the last two weeks that, although primitive, it is a full simulation with an animated visualization.

A highlight of the month was using emacs for scheme development. While working on my complicated code, I had to move away from running it in the browser so that I could have a better debugging experience. As with many emacs packages, setting them up and learning how to use them takes some time and can be bumpy. Once one gets the basics, one is super productive.

Understanding repl development was a big revelation. I had heard people talk about how great the experience is. I have seen some videos. These didn't seem that different from using the ruby or python repl. Working directly in the repl made me realized what the excitement is about. I will try my best to share it, knowing that this must be one of those things everyone must experience ourselves to fully appreciate it.

Being able to update a single function while the rest of the system is still running is mind-blowing. After we come down from the religious experience, we discover that this little feature makes development very productive.

Another interesting discovery was how having different scheme implementations, which I initially saw as a weakness, is actually a strength. The language is pretty much the same in all of them. Having different implementations available allows us to pick the one that helps us achieve our goals with minimum ramping up time.

Next month I am planning on writing three small scheme projects. One is a game, of course. One is a small web app and the other one will be a small web server. Let's see what I learn next.