Garbage Burrito

Ben's Really Long Ruby on Rails Story

Ben's Really Long Ruby on Rails Story
Ben Kittrell - 09/07/2006 11:35:00
Comments: 2
Last Comment: 11/28/2006 10:48:41
I've been talking about Rails for a while now, maybe more than I should.  Ryan made a smart-ass comment on my rant about Java, and unfortunately he's right, I am infatuated with Ruby on Rails.  It made me think about why I started using it, and my experiences with it, so I'm now inspired to write.

In the beginning.  

I love Java, I really do.  I've been using it for quite a while now, and really started to get excited when I learned about the new frameworks like Hibernate, Spring, Tapestry, etc.   I was passionate about this new world, until I realized something.  All of my experience is with web development, and there are two hard truths about this world, HTML Forms and Relational Databases.   These are the two technologies we are pretty much stuck with using, and 90% of web applications are just forms feeding databases.  Now form data is pretty simple, and pretty tabular, and so is relational data.  You've got keys and values, with a few data types in SQL like datetime.  Now in what way does it make sense to jam a strongly typed, object oriented language in the middle?  How much effort should we put into converting form data into a typed data model, just to turn around and extract it so it can be inserted into a database?  Now if you have some sort of complex business process in the middle, then you've got a good reason, but lets face it, most of us are just storing and retrieving data.

So this started to itch.  I thought, why doesn't someone create a language specifically for web development and moving data between forms and databases?  Well duh, that's exactly what PHP is for.  Unfortunately PHP alone leaves much to be desired in my opinion.  My PHP experience goes way back to before I touched JSPs, and it will always have a place in my heart, right next to Perl.  I had learned many things from Java about separation of concerns, keeping maintainable code, and other good coding principles, none of which I've found in PHP.  I know that much has changed, and there are now frameworks for PHP, but we're still over a year ago in the timeline of this story.

I really wanted this new mythical language, I even (briefly)considered trying to create something myself.

Ruby on What?

Then I heard about Ruby on Rails.  I don't remember the first time I read about it, but I do remember reading Howard Lewis Ship saying that if he had the chance, he would re-write Tapestry using Rails.  I'm not sure why he would write a presentation framework using a full-stack MVC framework, but that is my earliest memory none the less.   

I read all the hype, and like most Java developers just shrugged it off.   I didn't like the idea of the framework dictating how my database model should act, I also didn't like that it wasn't even 1.0 yet.  I found Trails, a Java framework that emulates Rails using Tapestry, Spring and Hibernate.   I tried it out, but it didn't feel right.  When I'm in Java, I want to use Java idioms.  Like I said in a discussion with Dave, "Ruby is a pickaxe and Java is a Jackhammer. No matter what kind of tip you put on it, it's still a Jackhammer."

My wife was selling some antiques online, and she wanted a system to track everything.  I figured this was the perfect excuse to try out Rails and see what all the hubub was about.  I finished it over the weekend.  It was a fairly simple inventory system, tracking products and customers.  I was even able to integrate it with USPS.  But I was still amazed that I could churn this out so quickly, even though I was learning as I went.

First Impressions

What really impressed me at first was how they thought of everything.  Every little problem that I've had to solve over and over again was right there in the framework.  Things like how to handle collections of form data, and auto-formatting content using HTML.  I could tell that whoever created this, was solving real problems, and not just thinking about what might be cool.  But what really started to sink in, after I really got into it was how little I thought about the framework.  I spent a lot less time worry about where to put things, and which config file to edit, and a lot more time worrying about the problem at hand.  That's when I realized the power of Rails.  It's not just about scaffolding, or dynamic typing, or other tech stuff, it's about constraints.  Before, I didn't have any constraints.  I was free to intermix any number of frameworks together to create my own.  But I realized that the complexity that this adds to your environment impedes your development effort.  By placing constraints on yourself, you simultaneously free yourself from them.  You can forget about them, and worry more about solving real problems.

I could spend all day telling you about the cool stuff that Rails does, but it's what Rails is that makes it special.  

Putting it to the Test

At the beginning of 06, Heath and I started DoodleBit.  We had a client asking for a website with discussion forums, content management, and possibly photo galleries.  I wanted to write this myself, because I've had bad experiences integrating off-the shelf-stuff together.  The main issue being a centralized user database.  It didn't have to be super complicated, just the basics.  So I was faced with the question, Java or Rails?  I started writing it using Struts, Spring and Hibernate.  It was going well, but I just kept wondering if it would be easier with Rails.  I decided to write a small piece, just for fun, but I ended up re-writing everything I had already done in Java.  In one day I accomplished in Rails what took me a week to do in Java.

In a few weeks I had it finished and ready to go.  Forums, CMS, Blog, User management, and a Templating system.  Not only that but I still had a maintainable code base, I had unit tests for everything, and I didn't feel bad about it.  Since then I've added Photo Galleries, an RSVP Form, and filled it with other little goodies.  I've also created a billing system that integrates through a web service.  Don't worry, it's coming soon.  

I've created a few other applications, including a shopping cart, and it just keeps getting better.  I thought I would find a breaking point, at which all the abstraction would hold me back, but it hasn't happened yet.  

I learned a lot about proper application design through Java, and I gave none of that up in using Ruby on Rails.  Sound and proven concepts like MVC and ORM are baked in.  New paradigms like REST are on the way.  Rails is built on good theory and practice.  And most importantly Rails is an extraction from real world applications, and is not designed by committee.

To the Future

I have had a few eye openers though.  There have been times when it's been hard to find good libraries in Ruby, and I was a little surprised to read about troubles with internationalization.  And of course the recent 1.1.5 fiasco, left me a little worried.  These things make me re-consider my choice to invest so much in Rails, but ultimately I look to the future.  I myself cannot deny the amount of attention Rails is currently getting.  Some say it's just hype, and that it will fade, but I don't think so.  Web 2.0 is hype, Flex is hype.  Rails will last, and everything around it will flourish.  

I'm the type of guy, that when I tell you something I heard I will qualify it with "well, that's what I heard anyway", instead of stating it as fact.  I don't like to say definitive things, cause I don't like to be wrong.  But I am saying, right here and right now, Rails is going to continue to grow, and it will dominate the web application development landscape.

I have enjoyed my experience with Rails.  It's fun to program again.  I like programming, because I like solving new problems, and Rails lets be spend more time doing just that.

Disclaimer:  I know I'm probably asking for some doofus to come in here and tell me why I'm stupid, for whatever reason.  Save your breath, these are my opinions and experiences, and this is not meant to spur any arguments over any topic. 
Comments: 2
Last Comment: 11/28/2006 10:48:41

Comments

1. Vinnie   |   09/14/2006 08:49:59

"These are the two technologies we are pretty much stuck with using, and 90% of web applications are just forms feeding databases. Now form data is pretty simple, and pretty tabular, and so is relational data. You've got keys and values, with a few data types in SQL like datetime. Now in what way does it make sense to jam a strongly typed, object oriented language in the middle? How much effort should we put into converting form data into a typed data model, just to turn around and extract it so it can be inserted into a database?"

Totally agreed. Shuffling and converting data around between types is probably the biggest time-waster in JSP. :(

2. Nik   |   11/28/2006 10:48:41

Totally aggree but most of the time we do the same for 90%

Post a Comment


Are you human? Please enter the word below.
M2jsdwuuanbnmti2otiwodmxoq==


powered by Doodlekit™ Free Website Builder by Doodlebit™ Website Company