Friday, December 28, 2012

Seven Languages Week 1 - Ruby

I just completed the first chapter of Seven Languages in Seven Weeks which focuses on Ruby. On the assumption that the other six languages will follow the same pattern, the author divvied it up into three separate "days" (which was welcome as I'd been expecting 7 lessons which would dramatically lessen the chances of me completing any of these in a single week). The first lesson teaches the basic syntax of the language, the second lesson ties things together with more complicated structures, and at least in the Ruby chapter the third lesson was designed to show off "something cool" about the language - in this case, the metaprogramming facilities of Ruby.

I've had some minor experience with Ruby before, about the same extent that this book provided - the sort of introduction one gets over a couple of lectures or a 30ish page book chapter. As such it wasn't too confusing but we were definitely in the shallow end of the Ruby pool.

My first (err, second) impression of Ruby is that if one ignores Rails that there's not really any reason to prefer it over their favorite scripting language, e.g. Python, Perl, etc. I'm sure if a Ruby zealot was reading this they'd come up with a thousand reasons why I'm wrong but I simply can't imagine enough power existing in Ruby to warrant the sort of time investment it'd require for me to reach for Ruby first as opposed to something like Python (which I'm much more comfortable with) for scripting tasks, glue code, small apps, etc. Both are dynamically typed, object oriented languages featuring duck typing, metaprogramming facilities, functional programming trappings, etc. I'm sure one could spend all day describing how one tidbit was better in their favorite language in this fight but if I had to spend hundreds of hours achieving that level of fluency in the 'other language' it ain't worth it. And the last word on the silly Ruby vs Python debate that I just created - the Rubyists seem to love jumping up and down being sooo proud of "everything is an object!", which is something that always turns me off from a language (the zealots always spouting it, not that the statement is true).

All that said, what little I've seen of Rails was promising but this book didn't cover Rails at all. I have a fair amount of experience with Django (a popular web framework in Python) which was easy to use but Rails seems particularly easy to use and quick to develop on.

As promised, my solutions to the exercises (which could probably be gleaned from a google search) are available on my github account. I ran into a few minor road blocks - on Day 2 I spent a lot of time figuring that there had to be a much better solution, and on Day 3 I had misread the problem. Neither are really worth talking about here - after looking around on the web it seems that most people arrived at similar solutions (with varying degrees of proper Ruby idiom).

Tuesday, December 25, 2012

Seven Languages in Seven Weeks

About a year ago I bought Seven Languages in Seven Weeks with an eye towards broadening my horizons in regards to programming languages. The idea of the book is stated by the title - the author gives you a brief introduction to seven different languages spanning multiple programming paradigms with the idea being that one spends a week on each. The languages were mainly selected on the basis of being less common (e.g. Python and Javascript were removed for Prolog and Io respectively) but yet somewhat well known/useful. Each language is separated into three lessons which come with a bit of homework - both reading (e.g. language API) and programming assignments.

I finally managed to find some time and sit down with the book and have worked through the first two days of the first language - Ruby. I have a small amount of experience from Ruby, having previously started the Coursera SaaS class (granted 'started' means only the first week or two). I'll make a Ruby specific post when I'm finished.

I'm also planning on putting my solutions to the coding questions on my Github account - I'm sure they'll make someone with real experience in the language cringe, so if anyone happens to come across this and want to give me some constructive criticism feel free.