Why Ruby on Rails is better then PHP
I’ll admit - I’ve been a fan of the LAMP for a long time. When I started out, like many new web designers I needed ways to do things dynamically. I remember my first form to capture data to a text file using PERL. It didn’t take long before I got sick of the picky uploading requirements and file permssion setting that PERL required. I was looking for a faster, easier plug and play way. Ah at last - PHP. I could pretty much copy and paste code snippets as a newbie and scripts were working immediately. Now and then an error would pop-up - but delightfully followed with a tip to “go to line…” whatever to fix my “parse errors”. Yes I was and still am a huge fan of PHP.
It wasn’t until some of the best PHP developers I knew wondered why I was doing things so “inneffeciently” that I started probing RoR. Now I’ll admit - I’m far from conversant in Rails as I’m a webmaster/designer type, but I have learned a few things that have influenced me and our organization to switch over to the rails framework for new applications. Here are a few reasons we made the (95% of the time) switch. I say 95% of the time because there are still cases when we find the framework may not be the best option - but that’s for a later post.
I’ll admit - I’ve learned these benefits from the pros I work with who write the language. Adrian Madrid of HyperX first introduced me and I’m glad he did. Others have had to force the logic into my brain - but I’m starting to ‘get’ it.
- Rails has an interactive shell that lets you write and execute code directly. No queries…just simple code.
- Database abstraction. Being able to loop through rows with just one simple command rocks. Remember php while … In rails the same thing would be something like this: table.each do |column| is pretty cool. Of course you can still run queries, but the most common ones are taken care of. It also understands relationships if you let it.
- Working with databases as objects is a great time saver.
So there you have it - yes it is better then PHP. Where is it headed? I’m not sure - but folks around here cringe if I mention doing new projects in PHP, and smaller projects are typically finished in half the time - so I’m sold.