The Reasoned Schemer

The Reasoned Schemer by Friedman, Byrd and Kiselyov is one of those deceptivingly thin books that are packed full of content. It’s written in the same style as The Little Schemer and The Seasoned Schemer, namely in form of questions and answers that slowly teach you how relational programs are written. Slowly probably isn’t the correct word though, as the book is only 160 or so pages long, so the pace is actually quite high and at least I couldn’t internalize everything in one go (not even after re-reading it multiple times).

The book isn’t bad though, on the contrary. It’s very well written and very approachable. I often end up leafing through it and re-reading parts here and there when I’m waiting for the water to boil for example. The book is divided into bite-sized pieces and it’s easy to get started.

The book is about adding logic programming into functional languages (namely to Scheme), teaching how to write logic programs and showing new ways to solve old problems. Programming language shown in the book is called miniKanren and there exists multiple implementations of it for various languages. Idea behind the language is deceptively simple: describe things and their relations and let the computer figure out solution to your problem. Programs are composed of goals, which describe simple relations between things: “a is equal with b”, “first item in list c is ‘X'”, “rest of list c contains ‘Y’ and ‘Z'” and so on. The seemingly magical thing is that while functions usually run in one direction (take parameters, process them and return answer), goals can be run to any direction (within certain limits). It is equally easy to specify that first element of some list is ‘X’ as it is to check if that really is case. It’s even possible to let the computer generate bunch of lists that start with ‘X’.

While the book is easy to read and written in very friendly and humorous tone, it will take a long time to internalize everything explained in the book. Be prepared to read and re-read it over and over again, if you want to really understand what the relational programming is about. It’s very well worth the effort though, if for nothing else than broadening your horizon.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s