Tag Archive for practice

Io, Io, it’s off to work we go

The second language covered in Seven Languages in Seven Weeks is Io. If you’re like me and enjoy Googling for help learning a new language, this one is tough. The only real sources of information about Io seem to be the official website and answers to the questions raised in this very book. As of this writing, there’s only 39 questions tagged with “iolanguage” on StackOverflow (compare to Ruby’s 71,477).

That being said, Tate picked Io because he “struck JavaScript because it was too popular and replaced it with the next most popular prototype language…” He also indicated that he had a much stronger understanding of how JavaScript worked after learning Io.

One thing I struggled a bit with is that most commands in Io read backwards compared to what I’m used to from other languages, but not always.
print "Hello, World!";
echo "Hello, World!";

# Io
"Hello, World!" print
write "Hello, World!"

In the first example, Io is sending the message print to the sequence “Hello, World” while, in the second example, the sequence is being passed to the write method as an argument. Loop constructs also can work from both sides.

# 0..9
for (i, 0, 9, i println)
10 repeat (i, i println)

Tate does spend a section talking about how Io is powerful when building a domain-specific language. Like Ruby, Io let’s you replace any built in functionality with new versions. For example, in one of the daily lessons, the book has you replace the built in division operator (“/”) with one that returns zero if the divisor is zero.

Overall, I felt that the real meat of this section was in the first lesson, while the other days were merely code exercises. I found this section severely lacking compared to the one on Ruby, which is Tate’s “native” language. I won’t know if that is a criticism of the book or just this section until I finish the next.

Ruby == Mary Poppins

Prior to reading Seven Languages in Seven Weeks, my exposure to Ruby was very limited. In a “hands on” sense, my only experience was installing Graylog2, a log management package. It is written in Ruby and I needed to work with Rake to get it installed. This wasn’t hard as PHP’s Composer draws heavy inspiration from Rake.

Other than that, my knowledge of Ruby was what I gleaned from the occasional blog post that hit the front page of HN comparing PHP and Ruby. Most of them focus on syntax and how much less code you have to write in Ruby to accomplish the same thing.

Bruce A. Tate explains this as syntactic sugar, “those little features that break the basic rules of the language to give programmers a little friendlier experience and make the code a little easier to understand.” And, throughout this chapter, I was able to really see that mentality shine. From tools to easily list the methods available on an object, to the names of boolean methods ending with a question mark, it really felt like a language in which clean, readable code is easy to create.

I found all of the examples and self-study challenges easy to complete probably, in part, because Ruby is a loosely-typed, object-oriented language just like PHP. Thanks to their well-written API documents and StackOverflow, anything I needed to look up was easily found.

In the last few pages of the chapter, Tate touched on the weaknesses of the language. I knew that performance was a concern as, years ago, the Penny Arcade folks were bemoaning their Rails site. On top of that, I worry that Ruby might lend itself to easily creating “clever” code that’s hard to debug and change. Tate really emphasizes Ruby as a tool to get your product to market which lets you worry about scaling issues later; this was the case for Twitter, which started out as Ruby and then rewrote core parts of their application in Scala.

Seven Languages in Seven Weeks

I always recommended Teach Yourself Programming in Ten Years to junior developers as a path to expand their skills. With some gentle prodding from a friend, I’ve decided that it’s time to take some of my own advice and focus on one of the recommendations from that article:

Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).

My professional work has been almost exclusively with PHP and JavaScript. I did a number of VB projects during school and there’s always a few tools you need to use or modify in other languages, but my experience with Ruby, Python and Perl doesn’t extend much beyond configuration, compiling and installation.

Recently I read through a good bit of Learn You a Haskell for a Great Good but I feel like I need a resource that’s more dedicated to teaching me what makes the language different and what it excels at, rather than an API reference guide. Enter Seven Languages in Seven Weeks by Bruce A. Tate.

I Will Take you Beyond Syntax
To really get into the head of a language designer, you’re going to have to be willing to go beyond the basic syntax. That means you’ll have to code something more than the typically “Hello, World” or even a Fibonacci series.

The book covers Ruby, Io, Prolog, Scala, Erlang, Clojure and Haskell which gives an amazing smattering of different typing and programming models. I’m really looking forward to working through the programming examples and challenges in the book.