Learning Ruby on Rails

Wednesday, June 13, 2012

Learning other Languages

ailatan / Free Photos

It's often said that a good developer should have as a goal to learn at least one language a year. I am not sure how important that is as goal, but I have to admit that at this point of my career , this is where maybe I have been a bit lacking. I have managed to stay relevant with the latest features of .Net and I am currently working a lot with the new MVC 4 features, like Web API for example, which is currently a release candidate. Still, I haven't spent too much time learning other languages. I have actually not had the need to learn other languages because because the places where I have worked, for the most part, have been .Net shops. However, not having the need is a bad excuse, so this year especially, I have been setting out to rectify this imbalance and learn other languages and frameworks. 

Furthermore, .Net has becoming pretty mature now, and I don't see anything coming up in the near turn that is going take a lot of time too wrap my head around. Maybe async and the new mobile features coming out might take a little time, but other than that, there is not much out there that if I need to learn, I could spend a few days and get up to speed pretty quickly. I mean to say, that Microsoft seems to be spending their efforts on making the current features better, and not introducing a lot of new features, like they have done in the past.

Why Ruby on Rails

I suppose I could have chose Java or PHP, and I have actually been playing around with Node.js for a bit (does Node.js count? It's JavaScript after all). I actually set out to learn Spring in Java but had a hard time just getting a simple "Hello World" app on my Windows machine. Plus, I couldn't find any decent free tutorials to get a newbie like myself started.

I have been fascinated with great things I keep hearing from the development community about Ruby on Rails, and knew that there were a lot of really good resources out there on the language, so I chose to take look at Rails and see what it had to offer.

My Approach

So to get started on this endeavor, I started watching a video series. For me, I find that videos help be get off the ground quickly and then at that point, I can then read a book or two to help me supplement what I saw in a series. 

A couple of years back, when I was first learning ASP.Net MVC, Rob Connery, published a bunch of videos on the asp.net website where he built a MVC eCommerce site from scratch. I liked his approach and easy going manner in the videos and knew that he had created his own learning site called TekPub. I also knew that he had a series on Ruby on Rails, so I put down the money (pretty nominal for the amount videos I got) and began watching the series.

In the series, Rob first goes though a lot of the basic concepts in Ruby on Rails and then later in the series he takes those concepts and starts building a project time tracking application. While he goes through and builds the application, I have been following along and been building the same application trying my best not to copy his code, but writing it by hand in a TDD/BDD approach.

The videos are really well done, so if you are looking for place to start, as I did, you will not be disappointed with this series. Beyond that, I watched a lot of Railscast.com videos for specific Rails functionality. For example, I went there first when I wasn't sure how to go about adding functionality to my models and found the right video pretty quickly. The videos here are quick 10 to 15 minutes nuggets that showoff a specific functionality of rails. These videos are also really well done.

And as always, I have been spending a lot of time Googling. I haven't come across a question yet that I didn't find the answer to by simply searching for it.

My Current Status

So although the video starts building the time tracker web application it doesn't finish it, and since think I could probably use something like this for my side projects, I am pushing forward and am going to see if I can finish this application to at least the point it is production presentable. When I am finished, I am going to put the code on GitHub and see if I can find a free Rails hosting site I can host the application from.

I have also bought the book Eloquent Ruby to assist me with the Ruby language in general. I probably should have went through this book first, as I am finding while I am building the application that there things I want to do and to do them I have to spend a lot of time on Google for the write syntax and approach.

What I Like So Far

After, spending a lot of time in Ruby on Rails recently, I can really appreciate now where a lot of inspiration for ASP.Net MVC came from. Rails does MVC beautifully.

Not being a strongly typed language Ruby on Rails has to depend a lot more on writing tests than ASP does, and to that end, I think the test tooling you can get with rails is pretty awesome. I have been using RSpec for unit testing and Cucumber for acceptance testing. Both those frameworks are really expressive in a BDD style of writing tests and not very difficult at all in learning how to write. FactoryGirl which is a test stubbing tool that can generate a lot of test records for you is the bomb. I wish there were something equivalent to it in the .Net space. All of these frameworks have really good documentation and videos on them.

Ruby on Rails takes "Convention over Configuration" to the next level beyond any thing I have seen in .Net. From setting up a database, to setting up routes, etc, Rails uses conventions all over the place, and if you can take advantage of them, they can save you a lot of time in writing extra code.

Code generation in Rails is really good, and although I am not a fan of scaffolding per se, (ASP.Net MVC does scaffolding too), I really like the simple code generations you can do, and the ability to create your own code generations too if you want.  

There is a ton of documentation, videos and other resources for the newbie developer. There are a lot of functionality you can add to your application simply by adding the reference to in your gemfile. This also has its drawbacks in which I'll discuss later, but its usefulness far out weighs the negative impacts.

Security is more straight forward and easier to implement than it is in an ASP.Net MVC application. The out of the box implementation does what I need, so there is not much code I need to write for the authentication and authorization functionality.

What Could Be Better

I got admit there is not much I don't like, and none of things I am about to mention are really big issues to me, just things that maybe I would just put on my wish list.

One thing I have found is that rails is so dependent on its development community and its community is so diverse, that I am having a hard time keeping up with all the Gems I have downloaded for my application. From watching the TekPub videos to now, there have been a lot of breaking changes that I have spent a lot of time fixing.  There has been a longer than expected learning curve in learning all these different GEMs and all the magic they perform for my benefit. Also, the multitude of Gems makes it hard to go out and get a book to learn Rails because inevitably the book is going to use Gems that might not be what you need for the application you need to write.

I haven't really been impressed with any of the Ruby on Rails IDE's. I love and can't live without Jet Brains Resharper plugin to Visual Studio, so I figured Jet Brains RubyMine IDE would be a good choice; however, I have found that although its light years better than any other Rails IDE I have looked at, it's still kind of clunky, and not as polished as Resharper.

I know pure OO programmers poo poo Rails and its unwieldy inheritance, and I can see what they mean to certain extent. I can also see how a larger enterprise application written in Ruby could become a bit unmaintainable, but I think that's just a product Rails ability to quickly build an application and stand it up in a production environment. Actually, I think if your a thoughtful programmer, you can still write Ruby code that avoids most of these issues, as is the case in any language, it just might take a little more thoughtfulness in the case of Ruby.

Now, having both Rails and ASP.Net MVC in my tool belt, I can see where depending on my budget, and time constraints verses the complexity of the requirements and resources working on the project, I might choose one framework/language over the other. My view could change, but I could see using Rails for my sites I want to get up and running quickly at a low cost, where a more enterprise level application, I would probably go with ASP.Net MVC application. However, I would relent to the fact that this view could just be based on the fact that I am more comfortable with what I know and this is not necessarily a reflection on Ruby.

Conclusion

So far, I am glad that I spent the time in learning this language. I think, in general, its made me a better programmer do the fact that my eyes have been opened new approaches to building a quality software products that I haven't really seen before firsthand. I like Ruby on Rails and look forward to writing more applications in this language.

When I finish my application, and publish to GutHub, I'll also write another post which will be an update on my experience. 

 

 

comments powered by Disqus