Friday, December 23, 2011


With an end-of-year project sprint, the Japanese language test and family health issues, I been feeling a little drained lately. I'd normally relax and recharge by studying Japanese, by doing photography and by writing on this blog. But I want to get away from studying for a while after the JLPT test; I don't have the uninterrupted blocks of time needed for camera walks and processing the results; and most blogging feels uncomfortably close to work right now, aggravating my stress rather than reducing it.

So, I need a new interest. Something I can do wherever and whenever, and in small snatches of time. Something I know I enjoy. Something like learning a new programming language1.

A student programming a robot. Good "programming" illustrations are hard to find.

I've enjoyed programming since before high school, I've worked as a programmer and my undergraduate subject was computer science. All you need is a computer. Most languages have lots of good documentation and tutorials online, and you can bring a book for when a laptop is too much. You can read and practice in short increments whenever you have a bit of time. And programming is just like doing puzzles or word games: you give your mind a challenge, occupy your thoughts for a while and emerge refreshed and happy.

But what language? There has been an explosion of new languages, or new interest in old languages, recently. Haskell, Erlang, OCAML, Javascript, Dylan, Scala, Go, Groovy, Kawa, Dart, Clojure… They all promise to be hip, webby, cloudy and concurrent, and they all claim to be the Next Big Thing in computing. Hard to choose. Even harder to choose right. Ideally you'd want to know what a language is not good at, but that kind of comparison is rather hard to find. And the Next Big Thing more often than not turns into a Has Been overnight. Popularity is not a good way to choose.

Better to pick something that teaches fundamentals. One thing many, though not all, of the languages above have in common is that they are functional to some degree. Big, established languages like Python and Ruby also support functional programming. So lets go back to basics, I figure. Let's learn Scheme, and specifically Guile.

I know about functional programming of course. And I use functional constructs in Python and other languages from time to time. But I've never tried to really live a functional life as it were, and I don't have an intuitive sense of how to do it right. By learning and using Scheme I will hopefully not just gain a new language but also enrich my programming abilities in general.

Scheme is a LISP-like language, but very minimalist2. On one hand, it makes Scheme an easy language to implement, and it has made it a fairly popular scripting language. On the other hand, the base Scheme specification is so spartan it is very difficult to use. Fortunately, like LISP it has excellent support for extending the language with new syntax, so all implementations are fairly full-featured in practice. Small but extensible is the best of both worlds in a way, but as each implementation does things in different ways, Scheme programs aren't very portable between systems. Even seemingly basic things like looping are actually add-ons to the base language.

Guile is meant to be an embedded scripting language for Linux and other Unix-like systems. That is, it's made to be easily connected to low-level code written in C. You can write the main code in the low-lever language and use Guile as a simple scripting layer. Or you can make Guile the main part, and use C to extend Guile with fast application-specific functions. Or you can skip the low-level code altogether and just use Guile as a development language in its own right.

As it is easy to connect it to lower-level code there are pretty good bindings to many Linux system libraries; there's support for threading and parallelization; and like most Scheme variants it has a very good numeric stack with built in seamless support for exact values (using fractions rather than reals), very large values, complex numbers and more. It is a full-fledged development system, not a toy language.

Guile version 2.0 was released this year with performance improvements, support for compilation, new, better libraries and much more, but for now I will use version 1.8, as it is the current standard version in Ubuntu. The extra features of Guile 2 do not matter while I'm still trying to learn. I thought I'd post about my progress here from time to time.

#1 I know I just lost about 90% of you reading this. It's OK; we're all different and so are our interests. Just skip these Guile posts if you're not interested.

#2 Scheme people sometimes brag that the entire Scheme specification has fewer pages than the introduction to the Common LISP standard.


  1. This comment has been removed by the author.

  2. This periods with a lot of stress suck, really. But we'll pass them eventually. BTDT more or less.

    I began to listen music and it's somehow the hobby I've gotten for all the time and these moments. Photography is on the shelf too here.

    I am on my last year of highschool before university and it's stressing.
    Have a project to finish in 2 weeks and i've been stagnant in a point for about 2 days now. At least, having finished the classes and exams I can concentrate further into the project.

    I hope your relative's health problems go away soon, and he/she/them gets better. I too have experienced the student mind fatigue. Merry Christmas too!


Comment away. Be nice. I no longer allow anonymous posts to reduce the spam.