Scheme is “pimp your ride”

I’ve been toying with Scheme for quite some years, first with Racket and recently with Guile. I was never a heavy user of them, but I learned a trick here and there. It was not until today I realized that Scheme is the “Linux” of the programming languages (I’ll explain that soon).

Image for post
Image for post
Image by Robert Waghorn from Pixabay

Pimp my Scheme!

I was just playing again with the excellent book “Maze for Programmers” from Jamis Buck (ten minutes ago, to be honest) when I commented to my wife:

_ You know what? I don’t have fun like this since I learned Ruby for the first time.

_ Hmmm… So why don’t you write about it? — said her.

Great idea!

Made with Guile Scheme + Cairo Graphics (Guile-Cairo)

The crazy part is that it’s not the first time I play with Scheme, so why this time is being so fun? Differently from the past, now I’m not trying to learn the language as it’s supposed to be, I just gave it a shrug and said to myself “I’m going to use whatever appeals to my use.”

First, I don’t like to have different functions for doing the same thing on different data types. Stuff like “append,” “string-append,” “vector-append,” “something-else-append” are just… well, I don’t appreciate it. So, I want to use multimethods, and Guile has the perfect library for that, it’s called GOOPS (Guile Object-Oriented Something Something). Forget about the OOP part; it’s completely irrelevant (IMHO). Use it to have a function doing the right operation on similar types of data.

Also, I want pattern matching, so I used a Guile extension for it again.

Later, I got bored with “let” not being able to destructure my variables, so I started to use only “match-let*.” And now I’m renaming everything to things that make more sense to me, like “def” instead of “define-method,” or “var” instead of “match-let*.”

At some undefined point along the way, I’m not programming in Guile anymore. I’m actually programming in “Ronie’s language,” whatever that is. It’s not something I designed upfront, but the language is emerging from my use, naturally, to diminish the friction while I’m coding.

It’s my language! And it’s alive :D

So, is that a problem?

Well, I think it works the same way people like to get a bare version of Linux, like Arch Linux, and then customize everything to make it faster and more pleasant to them (Hi, Marcello!👋).

Scheme is my “bare language,” which I can add the modules I like to maximize my productivity and pleasure.

“Oh! But no one would be able to read my code besides me.” Well, if you are making something valuable enough, people will. Think Ruby on Rails, React or any framework that needs a book to explain how to use them. On the other hand, if what you’re building is not that valuable to others to bother, then, who would care about which language you are using?

Seriously, go experiment!

For the sake of completeness, here my “package config” for Guile:

  • GOOPS — forget about OOP, the core here is a perfect implementation of multimethods.
  • Pattern matching — I use it instead of “if” or “cond,” also to create a destructuring “let” with less parenthesis.
  • SRFI-88 — Keywords like “#:this,” seriously? I’d rather use them like “this:.”
  • Lambda — We are near 2020, so I think I don’t need to be afraid of Unicode anymore. That being said: λ.
  • SRFI-26 — Cut — Lovely small anonymous functions, boosted with Unicode to become Λ (upper case lambda).
  • SRFI-42 — Amazing list comprehension with really poor naming. Change their nomenclatures and be happy.
  • Threading macro — It’s impossible to program without it. Racket has a very mature implementation by Alexis King. However, I recommend the Guile version from Linus Björnstam to study about macros.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store