Still, learning a language teaches one new idioms, new ways of solving problems, and increasing the toolset available with which to solve problems. For those reasons I'm going to allow myself to pick up another language. However since there is only two months left in this year and I'm super busy with non development work, I'm not going to learn a full language and become somewhat familiar with its accompanying sets of frameworks, libraries, and APIs in two months. Instead, I'm going to take a minimalist approach and take a one day at a time shot at learning ruby. I'll be spending a single solitary hour on hacking ruby code each working day. Doing that from now until the end of the year should possibly teach me enough of the language to claim I know it on the surface and will let me know whether or not I want to continue with it in 2010.
But... why ruby?
- Everyone who I know that has picked up ruby has only good things to say about the language and API. I'm not counting rails here... just ruby the language.
- It looks more flexible than my current dynamic language of choice, python. For example, one sees tons of material about writing DSLs in ruby. For all of python's goodness, it doesn't feel like a good language to facilitate writing DSL's. I welcome any objections to that assertion, of course.
- The ruby developer community where I live is strong. Hashrocket, a pretty well known ruby (on rails) shop is a 7 minute bike ride away. There's nothing better than sharing with and learning from a kick ass group of tightly knit developers.
- I want something that isn't tied to JVM. I could have cheated with my selection and chosen something like Groovy or Scala, but I want something completely different. Scala is interesting and there are some neat functional idioms and concurrency support features intrinsic to the language that would be useful, but I'll save it until next year. For now I want to see what world is like outside of java land.
Day one was yesterday. I spent the first 25 minutes going through the Ruby in 20 Minutes tutorial (yeah... I'm slow) and the next 35 minutes starting to write a module/class to read in comma delimited files from the Netflix Prize dataset that identify a user id, rating, and timestamp for all ratings on a given movie.
In doing so, I managed to explore the following basics in Ruby
- File I/O (or at least reading files)
- The CSV module
- Iteration
- Attributes
- irb is a pretty neat interpreter. I'm a huge fan of the interactive python interpreter (and even bigger fan of bpython). The only thing missing here is the ability to see rdoc from irb - probably due to the fact that rdoc isn't stored as a member of any modules or classes the way that docstrings are in python (and accessible via .__doc__)
- Attributes are awesome way to remove boilerplate property code. It just reduces the noise of having tons of getX() and setX(Object x) implementations and calls to access the internal members of objects in Java.
- Reading in a file in ruby was just as easy and straightforward in ruby as in python. That's always a joy.
- The shorthand iteration of an enumeration threw me at first, but perhaps it's just a rubyism that will grow on me as I find out how to use it effectively.
file.each { |line| extract_rating_from_line }just didn't seem quickly intuitive the way that an equivalent list comprehension in python would[extract_rating_from_line(line) for line in file.readlines()]
or perhaps I'm just too used to python at this point.
0 comments:
Post a Comment