As a fun project I thought I’d participate as well and use the occasion to learn a different way of programming as an extra challenge. Ever since rediscovering Emacs I’ve been wanting to understand elisp better. Up to now I just considered LISP to be an annoying collection of parentheses containing bits of code. LISP code looks a bit like it was written by aliens. After considering a few options (Emacs with elisp, Common Lisp, Racket, Scheme). I picked the GNU Guile Scheme implementation.
Scheme is considered a minimal Lisp variant which made me think it’d be one of the easier options to start with. While not strictly required in Scheme, one of my personal goals was diving into functional programming, recursion and avoiding side-effects. Which meant I could not use iteration (for, foreach, while) and I was not allowed to mutate variables (change their values).
When telling my students they wondered if it was at all possible to write working code this way. We’ve only been teaching them imperative coding styles with some Object Orientated Programming up to now.
For me, it did turn out to be quite the challenge. It does not help that there are multiple implementations of Scheme such as Guile, Chez, and Chicken Scheme. Each implement Scheme in slightly different ways. So when finding documentation online, you have to keep in mind the code will need adjustments in order to work in the specific Scheme implementation that you use. The documentation of Guile itself is lacking in giving examples.
Still, when writing this post, I’ve solved everything up to day 5, and I feel I am getting better thinking in recursive functions.
Here’s my solution to day 1, my very first Scheme code. It works but is still full of newborn-schemer-ugliness.
After programming with it a few more days, it gets better though. Day 5 looks like this:
Want to see more? Check my Git repository
- Functional programming requires one to think different. You have to be more creative in finding a solution that works.
- After writing code like this for a few days, the parentheses seem to fade into the background.
- I find reading LISP code much easier now.
- There’s not a whole lot of grammar in Scheme, which makes all Scheme code look quite consistent, and thus easier to understand.
Aside from that, Scheme re-peeked my interest in programming languages. I’ve been looking into Haskell which looks super nice and Rust which is currently hyped everywhere. Both are completely different beasts from Scheme but very interesting nonetheless.
Another aside, looking into Scheme and LISP made me think about writing long(er) lasting code. Scheme has been around for 40 years. Scheme code still looks about the same as it did back then. You can still use Scheme (and LISP) to write modern software.
One of the things annoying me at writing code is that most code will stop running once a newer version of the it’s mostly the frameworks (Laravel, Spring MVC, ASP.net, etc.) which don’t seem to care about keeping code working.
If you’d want to write code which will still compile and run a hundred years from now, which programming language / environment would you use?
Want to dive into Scheme as well?
If you want to dive into Scheme as well, here are a few resources which helped me along the way: