Thursday, December 8, 2011

PHP Wins - Rails Fails


Web development has come a very long way since the turn of the century. With so many things changing on every level, it always amazes me that new programmers don't move on to professions that don't require as much caffeine and aspirin. Albeit, what drives a programmer is this insatiable passion to always know more. All rhetoric aside though, the fact that the world of web development is a very fast-paced, ever-evolving beast makes for some very identifiable separations between groups of programmers.


Having been a programmer for 20+ years now, I have been exposed to languages like Microsoft's™ Visual Basic & C#, Perl, PHP, and most recently Ruby. I currently work for an agency that acquired other development companies as well as their code bases. My strongest language has been and will likely remain PHP & Perl, but my work at this agency has forced me to learn Rails in crash course format and I must say, I find Rails to be more frustrating than trying to walk through an insurance sales convention with a sandwich board that boldy has "Potential (Sucker) Customer" printed on both sides.


Now, some of you might be immediately shouting at your screens and saying, "Yo, dumbass! Aren't you forgetting HTML & Javascript as languages?". Well, first let's just clear up the fact that those are not 'languages'. HTML, as the acronym states ever so clearly, is a markup language and it's sole purpose is for formatting content, not executing instructions. Javascript could loosely qualify more arguably as a programming language since it actually does perform stateful execution of instructions. But I think now would be a good time to inject that I am referring to true back-end, server-side languages used wholly for the development of full-blown application and business logic.


So, the real meat & potatoes of this post though was to address the rather significant differences between PHP CodeIgniter and the aggravating pitfalls of Ruby on Rails. Getting a narrative push-off started, I would like to first make the statement that new programmers should not confuse a programming language with a framework. These are two very uniquely different beasts and if schools are doing their jobs properly, they will drill that point into students heads relentlessly. They might put on a test, PHP is to CodeIgniter, what Ruby is to ________.


Both CodeIgniter and Rails are MVC frameworks. MVC or Model-View-Controller methodologies utilize the concepts of separation of business logic from presentation and that is well outside of the scope of this topic. But suffice it to say though that separation of business and presentational logic can be acheived without the use of MVC frameworks. It's just more like trying to convert a lawnmower engine into a car engine. It can be done, but not without exhausting every profanity out there and likely in multiple languages also. Nonetheless though, there are countless informational resources to be found on MVC development structures.


So, let's begin to compare antidotes & poisons...*coughs* I meant, apples & oranges.


First, we have Ruby On Rails:

Personally, I am not a very big fan of Rails on many levels. The framework assumes that the developer doesn't care about the lower-level details of the back-end and all they care about is rapid development. Although this can be good for certain designs, it clearly is not a framework for seasoned programmers that wish to maintain much more control over the application's internal processes and functional flow. Rails hides much of this from the developer and assumes that that's of no interest to the him/her. I'm sorry, but if convention over configuration is the new "in thing" then count me "out". That's for lazy developers. People afraid to learn about the systems and processes that are at the heart of their beloved Rails applications.


Here's a few of my hottest reasons for why I view Rails as a poor choice of frameworks;

  • It forces the developer into very rigid coding structures with little room for flexibility.
  • It boldly takes full control over database schema. (I'm sorry, but this is a BIG turn off!) Give me liberty or give me death!
  • The framework hides so much low-level processes from the developer that it actually kills the K.I.S.S. mindset entirely.
  • Setting up a development environment for a Rails app might as well be like pulling teeth. I have never seen anything this ridiculous since PHPCake came out.
  • A production Rails application is such a resource hog that no matter how much memory you open up on your server, Rails quickly absorbs it very greedily. In fact, one of our client's sites has to be restarted every couple of weeks just because of this fact alone.
  • Rails compiles and runs it's entire code base into memory. A first thought might be that this is a great thing, but it quickly leaves little room for the server to reserve memory for heavy queries.
  • Right when you thought you learned Rails, they shit out another version of it and totally ruin any chance that anything you learned from earlier versions has any validity or worth anymore.
  • Documentation for this ridiculous framework is about as scattered as the corruption of our government. You're only real resource is a few good souls on places like Stackoverflow. That's pretty messed up if you ask me.

I'm sure that you can tell that I am pretty anti-Rails, but I would like to go as far as to say that I have equal feelings about PHPCake for the exact same reasons.


Enter PHP's CodeIgniter (hear the ranks of angels singing?)

I'll get back to Rails shortly, just because it leaves far too much room for spite. Now here is an extremely well thought out MVC framework. It leaves a wonderful flavor on the palette and only requires a minimal of effort to get up and running. CodeIgniter has seen its bad days as any other up & coming framework has, but here are a few reasons why it has earned this *coughs* humble blogger's seal of approval;

  • It's extremely well documented.
  • Mildly painless when upgrading it on an existing application.
  • Extremely extensible.
  • Allows the developer to create a database that actually can perform referential integrity on its own rather than assuming that the database architects that created MySQL or what have you, couldn't possibly know how to make that happen.
  • Code execution can very easily be traced since the vast majority of the execution of the code makes very few assumptions about what you intend it to do.


CodeIgniter is pristine as an example of the best of both worlds. On the one hand, you can interact with the database entirely through ORM mechanisms if so desired. Namely, an ActiveRecord implementation. On the other, you can completely desert the ORM aspect and not even have to change one thing about the framework.


Back to Rails bashing now. (my favorite past time when not being extraordinarily productive with CodeIgniter)

Oh Rails...you treasure trove of endless pains in the ass! Okay, back to the fun. So, in direct contrast to CodeIgniter, Rails will ALLOW you to write your own queries, but god forbid you should actually have a table name that doesn't match the stinking model name. BOOM! In your face! Really?! I say, get over your self-righteous ass-umptions, Rails!


The original creator of Rails works for 37 Signals and that fact right there is why he invented Rails. He works for an agency and agencies typically are all about meat-puppet, high-volume development. I currently work for an agency, but I will say this, this agency is the exact inverse. The owner actually insists that everyone only work 37.5 hours a week as they refuse to have people slaving over their work. Now THAT is what I consider to be a mentality that fosters dedication from it's employees.

So, because the inventor likely works for a place that requires inhuman development volumes, the creator of Rails figured, and probably rightfully so, that the only way he could save his sanity and likely his job/ass was to create a framework whereby he didn't have to pay any attention to the lower-level workings of applications. This is fine until it comes time to debug. OH YEAH! I totally forgot about this little tidbit of shit with Rails...debugging!

GOOOOOD FREAKING LUCK WITH THAT!!!

You heard me. Yeah, Rails actually expects you to do all your debugging through the freaking development or production log file. Seriously!? Grow some error reporting balls! Oh...and when you do get an application error (and that is more likely than not), do you think you get intuitive debug info that actually leads you to the problem with any fair amount of relevant information? NOT! The only thing any worse than Rails error reporting is Microshit's .NET errors. *slightly vomits in my mouth*


Okay, so in closing, I would like to say, on the record, that I have a Love/Hate relationship with Rails. Stated simply, "I love to hate rails!".


I can't wait to see the shitstorm this blog post stirs up with all the diehard Rails developers that seem to think that this framework qualifies them, even remotely, as "developers". Bring on the lions!

13 comments:

  1. Haha, I like this post. Entertaining but also informative. Thanks.
    (p.s. I've been falling in love with CodeIgniter recently, but keep hearing about the magical wonders of Rails).

    ReplyDelete
    Replies
    1. Thanks Luke. :) I intended on it being precisely that. I had every intention of trying to add commentary that was direct, but slanted in somewhat pointed, but entertaining colloquialisms and such. Glad you liked it. And yes, Code Igniter is is truly an amazingly well thought out framework.

      Delete
  2. "The framework assumes that the developer doesn't care about the lower-level details of the back-end and all they care about is rapid development."

    - The framework doesn't assume anything. That statement reflects your incompetency as a programmer.

    "OH YEAH! I totally forgot about this little tidbit of shit with Rails...debugging!"

    This article is going to stir any storm. The above line is the most mindless, uneducated statement i have heard anyone say.

    "Rails compiles and runs it's entire code base into memory. A first thought might be that this is a great thing, but it quickly leaves little room for the server to reserve memory for heavy queries."

    - For someone who couldn't figure out how to use a Rails debugger, you seem to know an awful lot about memory management.

    "A production Rails application is such a resource hog that no matter how much memory you open up on your server, Rails quickly absorbs it very greedily. In fact, one of our client's sites has to be restarted every couple of weeks just because of this fact alone."

    - You are reiterating the fact that you have no idea what you are doing.

    You say you are being "extraordinarily productive". How? By coding boilerplate?

    "Technology is both our vehicle for innovative advances and our crutch, fostering laziness and very high dependencies on stuff that we used to do with our brains."

    - You should start using your brain again. It's healthy.

    ReplyDelete
  3. Oh, and for the record, I use PHP and CodeIgniter extensively and I believe they are great in their own respect.

    ReplyDelete
    Replies
    1. Hahahaha...you have the audacity to insinuate that I don't have a clue what I'm talking about? I have some news for you. I worked extensively on numerous Rails applications and environments and every last thing referred to in my post was very precisely based on repeated occurrences of each and every slanderous accusation I made about Rails.

      If you're trolling me, it's quite obvious that you're actually the individual speaking from a very low percentage basis of experience as your comments were not backed up by anything that even remotely represented a quantitative rebuttal about my positions, but rather just very loosely constructed and unsubstantiated belittlements.

      If you wish to come and troll, I will gladly ignore you. If you wish to come and prove me wrong by backing up your insulting comments with facts that remove doubt about my so called "idiocy", then I will gladly engage in and even encourage your direct assaults.

      Delete
  4. Well, I used CodeIgniter in several projects. That's the coolest PHP framework IMHO.

    BUT, as a CodeIgniter fan, I can clearly say that CodeIgniter is just a try to get all functionalities of Ruby on Rails to PHP... That's all.

    CodeIgniter developers just work hard to catch Ruby on Rails in PHP enviroment. But since CodeIgniter doesn't have neither REAL ActiveRecord model nor an ORM CI team should work much and much harder to be like RoR.

    Me?

    I'm using Rails now. And it's going pretty well.

    ReplyDelete
    Replies
    1. Scaryguy, I think you're confusing something here. CodeIgniter is not trying to "catch" anything to do with Rails. It is what it is, period. What tries desperately to to "be like Rails" is PHPCake. And I must say that that is a truly ridiculous framework. Cake is anything but programmer-friendly.

      The reason I stand so firmly on my position about CI, is that it makes no assumptions about the developer. It allows the developer the complete freedom to be confined to the rigors of the framework or to expand outside of the framework without having to worry that it breaks some convention.

      Rails is basically "rapid application development" for developers that just want to get something done without knowing why it works the way it does.

      Delete
    2. I don't think someone could use rails without understanding the lower level stuff. I learned PHP first and had to learn a whole ton of low level logic and syntax. When I switched to Rails I don't know how I would have had any idea what was going on without the previous lower domain knowledge. Rails does make many assumptions but you can easily change these along the way.

      The PHP world is definitely trying to catch up to Rails, Laravel is proof of that. I think you are just digging in and that is bad news for a developer. The field is so rapidly evolving that to retain such rigid views is career stagnation. I know you been developing for 20 years, but maybe that's is also the issue here.

      Delete
    3. I totally agree, maybe author need to dedicate more time to Rails to know that it is easy to debug, and when you learn some key words you can even intuit how to change the default behaviour.

      What I don't like about Rails are the reviews I have read regarding requests per second, in that aspect PHP seems to be win Rails. But this is not the biggest deal since you can just scale your resources, also there is a big community effort in putting together tools that increase Rails performance. Anyway if you look for performance I would take a look at Java world according TechEmpower benchmarks.

      In syntax, Ruby and Rails are friendlier for me.

      Thanks for the article, number one in Google, I recommend also to read http://www.leonardteo.com/2012/07/ruby-on-rails-vs-php-the-good-the-bad/.

      Delete
    4. Also read http://www.quora.com/Web-Development/Django-vs-Rails-vs-Node-js-vs-Code-Igniter-YII-Which-is-better.

      Delete
  5. It is nice blog Thank you provide important information and i am searching for same information to save my time Ruby on Rails Online Training

    ReplyDelete