7 Languages in 7 Weeks

A tour of non-trivial examples in different languages

I worked through the book Seven Languages in Seven Weeks, and very much enjoyed it.

You might be sceptical of the promise to learn 7 programming languages from 1 book, but this book actually delivers a wealth of information in a supposedly short duration. I say supposedly, because I started working through this book 4 years (!) ago, doing day-full hackathons together with a friend (Onno Huygen), making this project a 7 languages in 4 years journey. Nonetheless, the very infrequent weekends we spent diving into these seven different languages have been very rewarding. Here's why: the premise of the book is to give you just enough Hello World for getting a basic grasp of the language (Day 1), and then spend most of the chapter on non-trivial examples showing off the strength of the particular language (Day 2 + 3), possibly skipping over some details. Every language actually took a solid 3+ weekend days to complete, and we always ended up with a cool application using the more advanced language features. In most cases, we also came up with extra demos unrelated to the book. The author's goal was to teach different programming concepts, and therefore chose relatively unknown languages to keep it interesting. Nonetheless, most of them increased in popularity over the last few years. Here's an overview:

  • Ruby: the most familiar-looking language if you're coming from object-oriented programming, best known for Ruby on Rails; includes meta-programming and writing DSLs. We wrote a whiteboard drawing app and rumble-and-pass games using Wiimotes.

  • Io: a now forgotten prototyping language sharing some features with JavaScript; including being a prototype language, having object 'hierarchies' but no classes; we wrote an emulated post office (message passing and concurrency), and a custom HTML template renderer and web server

  • Prolog: having done most of my bachelor in AI in Prolog, this declarative logic-based language was familiar territory for me, but by far the most difficult language for Onno, who kept reminding me of the odd syntax, weird backtracking behaviour, obsession with recursion, and interesting matching behaviour. You won't have to write instructions on how to solve problems; simply writing basic facts and rules is enough: ask Prolog a question and it will do everything it can to try to make your question true. We built recursive sorting algorithms, solved Project Euler puzzles, and wrote a sudoku solver in 15 lines. True.

  • Scala: trying to bridge the gap between OOP and functional programming, Scala supports writing objects but prefers immutable state and functions without side-effect. We processed many collections using first-order functions, wrote a tic-tac-toe game, and wrote concurrent kid feeders (huh?) and web scrapers. I wrote about the follow-up course in my review of 2014.

  • Erlang: inspired by Prolog, Erlang shares a similar syntax and behaviour, but also adds a lot of new features, like having light-weight concurrency and message passing as primitives, running on its solid Erlang VM, and is built for reliability with a 'let it crash' approach; it lacks backtracking, but does give return values in return, making the code a little easier to read. We built a concurrent chat system that is monitored and automatically restarted on failures. An interesting successor language is Elixir, running on the Erlang VM, but with a Ruby-like syntax.

  • Clojure: as a modern LISP flavour running on the JVM, this language can piggyback on the mature Java ecosystem, just like Scala. As a LISP language, data and code are interchangeable ('homoiconic') and meta-programming is the norm. Nested lists might be hard to read, but it does make the syntax trivial, further simplifying data as code, and writing macros easier. We wrote collection processors similar to what we did in Scala, and wrote a concurrent barber shop using the built in Software Transactional Memory data encapsulation.

  • Haskell: a purely functional language, with syntax and type system that will please mathematicians, but will make hardware driver engineers cry due to overly complicated constructs needed for I/O processing. While most popular languages were developed bottom-up, building on top of current hardware details, Haskell - like Lisp - has been defined top-down from mathematics, making abstractions easy but low-level hardware access difficult instead. We wrote single-line sorting algorithms and custom-type card-games, all while trying to wrap our heads around Monads.

Of course, you don't actually know a language after 3 days. However, this book is the fastest way to taste just enough of a wide range of programming languages to know where you want to go next. I felt inspired by this survey-style resource, offering both breadth and depth in an accessible format. And guess what: this book resulted in a series, offering at least 7 "7 X in 7 weeks" in 4 years adventures.

 

        -------------------------------------
        |                                   |
        |           related graph           |
        |          /             \          |
        |       graphs         relations    |
        |                                   |
        -------------------------------------