Daniel Ziltener

Why You Should Learn Scheme Programming

Daniel Ziltener, 2022-09-23

The one thing that Lisp does give you is a better understanding of how things work at their core, and with that understanding, it becomes easier to learn other things.

Ron Garret, CoRecursive Podcast #076

We were actually trying to build something complicated and discovered, serendipitously, that we had accidentally designed something that met all our goals but was much simpler than we had intended…​ we realized that the lambda calculus—a small, simple formalism—could serve as the core of a powerful and expressive programming language.

Gerald Jay Sussman; Guy L. Steele Jr, The First Report on Scheme Revisited

What is Scheme?

For more infos, there is a long Wikipedia article about the history of Scheme.

In the beginning, John McCarthy invented Lisp. In the same year of 1958, the language ALGOL was developed at ETH Zurich. In 1972, Schemer was made by Sussman and Steele, which was a tiny Lisp with influences from ALGOL. In 1975, Scheme as an independent language came into existence.

Scheme is a programming language - well, you might have guessed that already.

What makes it great for beginners: it has very few rules; it doesn’t do much if any magic; and it is very interactive.

What makes it special for veterans: gives you a better understanding of how things work at their core; it doesn’t hide how it works; it is multi-paradigm; it teaches you the concept of continuations; and it is doable for a single person to implement it from scratch without growing gray hair.

Scheme is just a specification document R7RS ; the implementation we will work with in the subsequent posts is called Chicken Scheme. Chicken Scheme

The fact that there are a handful of different implementations on all kinds of platforms is testament to Scheme achieving its goal of being a minimalist language that is both full-featured and easy to implement.

Macros in Scheme are constructs that write code when called.

The small size also means that its basics are easy to learn, and that it does not hide its inner workings. Lots of functionality can be - and often is - implemented as macros on top of the core language instead of an extension like in most other programming languages.

Over the years, there have been multiple revisions of the language. The most recent one is called Revised7 Report on the Algorithmic Language Scheme, normally just called R7RS for short. This is the core language that has to be implemented to be a Scheme. In addition to that, there are Scheme Requests for Implementation, or SRFI for short. Those are either features or - in most cases - libraries that extend the core language. Most Schemes already come with many of the feature SRFIs build in. Most SRFIs, in however, are portable like normal libraries, meaning they only need the core language to work. They usually also provide an example implementation, so you can just use them with the Scheme you are using.

So why should I care?

Because even if you should end up not using it in the real world, you can learn a lot from it. You can use it, learn from it, extend it, even implement it in any language you choose. There’s a proverb in software development that every big enough software project contains an implementation of Lisp/Scheme.

Scheme scales beautifully. You can use it as an embedded small language inside a project’s code for rules or scripting, or use it for helper scripts and CI/CD, because the core language is so tiny. But it also does a great job as a full-blown high level language suitable for large projects by itself - not just due to its great language design, but also because of the vast array of SRFIs and libraries it can be extended with.

There are Scheme implementations for pretty much every platform and host language out there. Some compile directly to machine code, others like Chicken Scheme compile to C, others to JVM or .NET bytecode, or to JavaScript, WebAssembly, Rust, Go, you name it. It is also great for creating DSLs, Domain Specific Languages a famous one being miniKanren for logic programming.

It might just be the most versatile language out there, holding tons of lessons for your life as a developer, and tons of opportunities to use it in production.

    
    
(string-append "Have " "Fun!")