Introduction to Scheme

Published on September 17, 2015

Introduction to Scheme

  • Tutorial

The most important, but at the same time the most imperceptible property of any tool is its influence on the formation of the habits of people who tend to use it.
Edsger Vyb Dijkstra

Part 1 Introduction to Scheme
Part 2 Deepening in Scheme
Part 3 IronScheme Practice


In programming practice, there is often a need to write small scripts to automate various administrative processes, testing and monitoring. It is also not uncommon to need to embed an interpreter in an application or simply create a prototype to test an idea. For these purposes, you can use various popular JavaScript, Python, Lua, Bash, BAT, PHP tools and much more. And there is a need to store structured data in files or transfer over the network, when it comes to text formats, XML, JSON, CSV, even KV are usually used. However, despite the advantages and prevalence of such widely known tools, the obsession with finding a more flexible and elegant tool did not leave me alone.Thus, I once drew attention to the Lisp family of languages. And Lisp allowed to shoot at once all birds with one stone, and it’s beautiful and elegant. Since it has many implementations and standards for any needs and tastes. It can act both as an independent language and as an embedded language. It has a single format for representing data and program code. And most importantly, if necessary, writing your own interpreter is not an impossible task.

When should I use Lisp and when not? This article is devoted to various articles on the Internet. I do not presume to discuss this topic, but only notice where Lisp came in handy. For the most part, I used Lisp as an embedded language. To manage applications through the console, to create flexible configuration files, to store structured data, to transfer data over a network, to implement home -made home - made RPC. In my opinion, it is convenient when all of the above options have the same syntax and can still be expanded (in terms of syntax and functionality) and on the fly.

I do not consider myself a specialist in the Lisp world and I do not guarantee 100% accuracy of the material presented. One of the goals of this series of articles is to collect disparate information on various Scheme implementations in one place and in their native language. In general, this material is not for those who want to know why, but for those who want to know how. If someone will find the topic interesting and useful, write, we will clarify what is and think about the continuation.


Almost every article about Lisp starts with Lisp being one of the oldest high-level and general-purpose programming languages ​​that was invented by John McCarthy around 1958. Despite the antiquity of Lisp, it is a multi-paradigm language that allows you to write in functional, procedural, object-oriented styles. At the same time, all this multiparadigmality is available through a primitive and uniform syntax, the so-called S-expressions. To describe Lisp syntax in the form of Backus-Naura, only 7 lines are enough, with reservations of course. It so happened that over the long history of development over Lisp the best minds of computer sciences have puzzled, polishing it like a gem. However, you can’t say that Lisp is very popular, perhaps due to a frightening pile of brackets, because of which, at first glance, the program looks complicated to perceive. But after a little practice, discomfort passes into delight from the possibilities that this method of programming provides. At least it was with me).

To be more precise, Lisp is not so much a programming language as an idea, on the basis of which the languages ​​of the Lisp family are developed. Today, there are a great many Lisp dialects, and there are even more implementations of them. Which is not surprising, because writing a Lisp interpreter is relatively easy. So the wheel of history turned that Common lisp, Scheme and Clojure became the most popular dialects. Each dialect pursues its own, slightly different goals. Common Lisp is a rather old industry standard; it has in its arsenal not a small number of libraries and developments. Scheme - seeks to minimize the basic constructions through which all other functionality, a variety of styles and programming approaches can be expressed. That is, a minimalist interpreter and a developed standard library. Clojure - a fresh look at Lisp in general, many language constructs have been rethought for convenient development on top of the JAVA platform in the first place. As they write on the forums, developing under Clujure is much more productive and interesting than on JAVA. For the sole purpose of self-study, I tasted different dialects and their implementation. You can argue Scheme vs Common Lisp indefinitely, but for myself I made a choice in favor of Scheme for its conciseness, modernity and accessibility of implementations on various platforms.

You can find reviews about Scheme on forums, as if it is an exclusively academic language, which, if it can be used in practice, is extremely inconvenient due to excessive minimalism. Something told me, it is not so. And now, my dear reader, I’ll tell you that scheme, a rather flexible programming language, is not overloaded with cunning designs and can successfully compete with many popular tools. And using it as an embedded language is a pleasure. The relative simplicity of the Scheme standard plays into the hands of many other implementations. In fact, you can choose an implementation for any needs and develop full-fledged GUI, DB, WEB applications using Scheme as the main language.

There are plenty to choose from

It is curious, but often the most popular products practically do not provide a choice, here is the only and unique version for you, and everything else is either outdated or someone else’s homemade product.

Scheme, perhaps due to the simplicity of the standard, has quite a few implementations, either interpreters, or compilers, or both at once. Moreover, there are compilers in other languages, which in some cases can be extremely useful.

A list of known implementations can be found on the net, for example, a table is published on .
Known Scheme implementations

Name Link Type Platform Active R7rs
BDC Scheme interpreter Java no
Bigloo compiler many yes
BiT interpreter Hardware (microcontrollers) no
Biwacheche interpreter Javascript yes
Bus scheme interpreter Ruby no
Chez scheme interpreter (free) + compiler (paid) many no
chibi-scheme interpreter C (library) yes yes
Chicken interpreter+compiler many yes yes
CPSCM compiler Javascript, Common Lisp no
Elk interpreter C++ (library) no
Foment interpreter many yes yes
Gambit interpreter+compiler many yes
Gauche interpreter many yes yes
Guile interpreter many yes yes
Heist interpreter Ruby no
HScheme interpreter Haskell no
Husk Scheme interpreter Haskell yes yes
Ikarus Scheme compiler many no
Inlab-Scheme interpreter Linux no
IronScheme interpreter .Net yes
Jaja interpreter Java no
JScheme interpreter Java no
Kawa interpreter Java yes yes
KSI interpreter C (library) no
KSM interpreter C (library, Linux-only) no
Larceny compiler many no yes
librep interpreter C (library) no
LispMe interpreter Palm no
Llava interpreter Java no
Luna compiler .Net no
Microscheme compiler Hardware (Atmel) yes
MIT/GNU Scheme interpreter many yes
Minor Scheme compiler C no
MScheme interpreter Java no
mosh-scheme interpreter many no
NexJ Scheme interpreter Java no
Oaklisp interpreter POSIX no
Ocs interpreter Ocaml no
Owl Lisp interpreter POSIX no yes
Picrin interpreter C99 yes yes
Pixie Scheme III interpreter+compiler iPad yes no
Pocket Scheme interpreter Windows CE no
PS3I interpreter Java no
Psyche interpreter Python no
QScheme interpreter POSIX no
Racket interpreter+compiler many yes
Rhizome/pi ? ?
RScheme ? ?
Sagittarius interpreter many yes yes
Scheme 9 from Empty Space interpreter C89/POSIX, Plan 9 yes
Scheme48 ? ?
Scheme-to-C ? ?
Schemik ? ?
Schemix ? ?
SCM ? ?
Shoe ? ?
SISC ? ?
SIOD ? ?
SigScheme ? ?
Sizzle ? ?
Stalin ? ?
STKlos ? ?
SXM ? ?
s7 interpreter C yes
TinyScheme ? ?
UCB Scheme ? ?
ULisp ? ?
UMB Scheme ? ?
Unlikely Scheme ? ?
Vicare compiler POSIX/x86 yes
VSCM ? ?
Vx-Scheme ? ?
Wraith Scheme interpreter+compiler Macintosh Yes No
Ypsilon Scheme interpreter many no

And if you search thoroughly on GitHub , it becomes clear that there are even more options.

Following the standard in various implementations allows you to reuse code on different platforms, including for Web programming. But do not forget that functionality that is not part of the standard is likely to differ, which will lead to portability of the code.

In metal

More often in my practice I come across programming for .NET. Therefore, the solution that allows me to use .NET libraries and embed the Scheme interpreter in my applications is most useful to me. After playing with different options, I settled on IronScheme . So, how it, at first glance, seemed the most advanced implementation of the R6Rs standard for .NET. But there are others that will be written about in future articles.

IronScheme implements the sixth version of the R6Rs standard. Naturally, it has built-in functionality for interacting with the clr runtime. Thus, directly from the Scheme script we can create and manipulate .NET classes. And this is already enough to create a full-fledged application with GUI, DB and other goodies that are available from .NET. But we are not required to write full programs on IronScheme. Moreover, the supplied libraries have wrappers for a small number of standard .NET classes. Although no one is stopping us from helping the community.

Environment setup

  1. To start using IronScheme download the archive from;
  2. unpack for example in “Program Files (x86)”;
  3. add to the PATH environment variable "C: \ Program Files (x86) \ IronScheme \";
  4. for convenience, in the directory with IronScheme I create a file “is.bat” with the contents of “IronScheme.Console-v4.exe% 1”;
  5. By executing the IronScheme.Console-v4.exe command, run the interpreter in REPL mode.

Now you can enter commands, for example, "(+ 2 2)". The interpreter in REPL mode supports autocompletion by pressing TAB, which is convenient to use as a reference command or to check code fragments. To exit the interpreter, type “(exit)”.

Hello world!

By tradition, we’ll write and launch the Hello world application. In any familiar text editor, preferably supporting Scheme, such as Sublime , create a file and save it

The contents of the file:
(displayln "Hello, world!")

We start the command "IronScheme.Console-v4.exe" as a result we get the long-awaited inscription.