For a while now I've been hearing a lot of people taking about the programming language Ruby. Not that it's anything new, it just seems to be a lot more popular in my circle of friends and my Twitter feed. Naturally, as a professional PHP developer, I should hate the idea of Ruby and start some crazy argument about how PHP is far superior and Ruby should die (blah blah etc.. boring). Instead of this approach, I took it upon myself to learn Ruby from the ground up and understand why so many people enjoy using it to power their applications. Too many people argue over things without understanding both points of view, which always annoys me.
Really, learn all of Ruby?
Ruby as a language is obviously quite a large codebase due to it's maturity and years of existence but my goal here isn't to learn Ruby to the same standard of PHP which I have 7+ years of commercial experience with. Instead, I simply want to understand the language syntax, quirks and helpers that seem to make developers very happy and churn out apps like there's no tomorrow. I started by using a site called Code Academy which I used to think was for noobs but it's actually really helpful and I managed to do the entire course and have a published application in less than 24 hours. That an assumption I made without actually trying out the service. Never assume.
I'm not about to start another PHP vs Ruby war, this is simply me pointing out the most obvious differences in the languages and what my thoughts are. Firstly, everything is an object. It's majorly consistent and for that reason I think that's why it's so easy to pick up. Even though I hadn't read a lot of the course material I was still able to do most of the exercises by simply guessing the syntax or method names since a lot of it is common sense. Although PHP technically has Hashes and Arrays (both called just Arrays), they are more obvious in Ruby and you get a slight performance boost by using "Symbols" as Hash keys. There also seems to be a huge obsession with trying to get all code on one line in the Ruby community, especially with breaks, logical statements and raising errors. The more I write, the more natural it feels. There are many many more but that's not what this post is meant to focus on (maybe a separate post?) so I will let you explore the details more yourself if you're interested. The main point I would like to emphasise is that Ruby is easy. Almost too easy in a lot of cases. By that I mean there is about 3 or 4 ways to do almost every task within Ruby which is either a really good or a really bad thing.
Applying The Knowledge
What's the point in learning all of this new tech and not putting it to a good use? After I learned Ruby I decided to start an application from scratch to test out my newly acquired skills. Since Ruby is known as the language of Hipsters and I am a huge fan of todo.txt I decided to build a similar tool for the command line called Hiptask. I learned a lot of skills that weren't covered in Code Academy such as Unit Testing, dependency management, exception handling and publishing my own gem. Try it out and let me know what you think as I plan to continue development and use this myself on a daily basis.
Would I recommend Ruby? Hell yeah. Would I replace PHP with it? Not in the foreseeable future. Just because it's a great programming language and it's possible to write applications extremely fast it still can't replace a language I've been working with for best part of a decade. This is 100% my own personal opinion which may or may not change over time. If you are going to take anything away from this post then let it be this. Don't be afraid to learn new languages, techniques and skills. This is how some of the best code is born and how people innovate, develop as programmers and people. So what language should be next on my list?