« Back to home

Learning Ruby

Posted on

It has been a couple weeks since my last update. Not all my time has been devoted to this new project of mine. One week was spent working on a small startup that I am working on with a friend. Another week we went away for vacation. On a personal note, it was a bit strange going away on vacation while already being on a bit of a vacation.

One Book Down

I finally received the Ruby book I ordered, Eloquent Ruby by Russ Olson. I finished reading the book a couple days ago and I highly recommend it. I think it explained a lot about the intricacies of Ruby. The chapters were a good length – short enough to keep you interested, and long enough that I felt like I got a good understanding of each concept. I definitely had a couple “Aha!” moments.

The book isn’t really a Ruby language reference. It concentrates more on the concepts, which is what I was looking for. However, I’m tripping up a little bit on Ruby syntax still, so I’m looking for a one or two page syntax quick reference guide.

Because I was away on vacation while I read a lot of the book, I wasn’t able to crack open the computer and program along while reading. I probably should have mixed reading and programming to have it sink in a little better.

Thoughts So Far

I’m pretty sure I will regret these next couple paragraphs, but I’m going to write them so I have something to laugh at in the future.

So far, Ruby seems pretty interesting. The gem system seems great. The base library seems very useful and leads to succinct code. The documentation seems pretty good. I love that unit testing is there from the start. It will take me a little time to form an opinion on the dynamically typed nature of the language.

There are a couple minor things that annoy me. In no particular order:

  1. There are a couple syntax issues that seem a little off to me. First, the ability to use do/end or curly braces interchangeably – while there does seem to be some convention, it still bugs me a little bit when there are multiple ways to do the same exact thing. Second, the ‘do’ keyword seems a little unevenly applied – in some cases it is required (like in a each statement) and some cases where it seems to be implied (like a class or method definition). Wrapping pipes on looping/mapping variables is a bit annoying – one pipe would have been sufficient, I think.
  2. There are some aspects of the Ruby base library that seem a bit off: The naming of conversion methods (to_i, to_s, etc.) seems a little messy. Second, the eval method is poorly placed on the Object class. I think it should be a class method somewhere else.
  3. There seem to be a couple active versions of Ruby and I think there are significant breaking changes between versions. This fragmentation is unfortunate.
  4. I’m struggling a little bit with syntax errors. This could very well be my inexperience with the syntax, but a couple times I thought the error messages could have been more helpful.
  5. I miss stepping through code with a debugger – there is probably something out there, I haven’t looked. I find myself doing a lot of debugging with output to the console, which feels very dated.
  6. I miss Intellisense (a.k.a. autocomplete in Visual Studio). Sublime has some basic stuff built in, and there are probably some things I can install into Sublime to get better contextual help, but I haven’t looked yet.
  7. This is a bit of a personal preference, but I think fluent interfaces are often overused. I feel like the same thing is happening with rspec. The rspec DSL just seems to be trying too hard to read like English. This probably makes me old, but I prefer simple code. For example, I would prefer something like Assert(calculation != 53) over calculation.should_not == 53

These are probably the words I’m going to regret the most: My very gut reaction is that Ruby is a great language for scripting small to medium size projects. I feel like the lack of strict typing would lead to code rot on a larger project, such as a large line of business application worked on by many developers of varying abilities. In general, I think you need a decent amount of discipline to keep a large code base clean and I think the unrestricted nature of Ruby would make that even more difficult. Again, this is only based on gut feeling at this point. I have no experience with large Ruby projects to back this up. I’m sure there are thousands of large successful Ruby projects out there. It is just the reaction I had.