Things I’ve learned about Ruby on Rails

  1. Don’t use a model named Attribute, because “has_many :attributes” will bust your code for reasons I honestly have no interest in
  2. Instead of the popular string.replace(/foo/g, “bar”) convention for doing find and replace in strings, Ruby uses a funtion called gsub, thereby stealing another 5 minutes+ of my time looking this shit up for no good reason.
  3. There is some cleverness in RoR, but it is so bound up in brittle naming conventions that I doubt I will ever appreciate it. Especially the automatic assumptions based on pluralization of identifiers… god I hate this nonsense. Compared to this Python’s semantic whitespace is positively charming.
  4. Even though rand(n) returns a random integer from 0 and n-1, the condition “if rand(2)” will always be true, so you’ll have to write it as “if rand(2)==1″.
  5. default_scope would be very useful if it could be easily overridden in named_scopes. Unfortunately this is not possible, so a potentially convenient feature becomes an evil hack which you’ll have to remove at some point when it bites you in the ass.



(unfortunately I did not draw this comic)

I’ve been working in RoR for a few months now, and on the whole I think it is a pile of crap designed to help you write web apps for 2004. Contrast this with 2 other technologies, Git and jQuery, which I’ve utterly assimilated and embraced within the same period of time. Honestly I’d rather be working in PHP, because it doesn’t impose a methodology on you, nor create a million files for a “hello world” application.

9 Responses:

  1. Abhay Rana says:

    Have you looked into node.js? The frameworks are much more lenient and light-weight there. Or there’s always things like Sinatra.

  2. Mark2 says:

    I had such huge hopes for Jaxer….
    but now its Django for me.

  3. anthony says:

    Sounds like you needs some R&R from RoR…

    Gwt is my tool of choice. But that Google language (Go?) is dammed desirable. no exceptions, no implementation inheritance, no method overloading, no threads, no assertions, no ternary operator, no ++ operators ie KISS principle to the extreme has me thinking I maybe I can live with vendor lockin afteralll.

  4. Daryl Fritz says:

    With an attempt to engage in a constructive conversation, I’m pretty sure I wholeheartedly disagree with all three of your points.

    [1] Every single programming language and/or framework has reserved keywords that will trip up the interpreter if not caught by a compiler.
    [2] Are you really complaining about regular expression matching?
    [3] I agree, the whitespace-aware Python stuff is pretty nifty, but I would argue so is the Rails pluralization of objects.

    How can you compare Rails with Git and JQuery? All three are completely different tools. Similarly, you can’t compare Ruby on Rails with PHP; compare it with CakePHP or CodeIgniter. They all impose a methodology on you in some way.

    • mark says:

      1) the problem is that attribute *isn’t* a reserved keyword; using it just quietly causes an app to fail. This makes RoR feel half-baked.
      2) No. I am complaining about non-standard function naming. String.replace in Ruby means something utterly different from what anyone would expect. This also makes RoR feel half-baked.
      3) In fact I think semantic whitespace is a bad idea as well… this and the RoR propensity for implicit object and collection names through pluralization are both completely half-baked IMHO, because in both cases it blurs the line between syntax and style. Syntax in a language should never be ambiguous or vague or squishy. It should be clear and as simply described as possible.

      I compare with Git and jQuery because they are two technologies I had to take up at exactly the same time, and they were both as alien to me as RoR, and yet both proved their worth within days, whereas RoR seems like someone’s pet project that took off long before it had stabilized or matured as a product.

      I compare RoR with PHP because no one would consider writing a web app in Ruby alone, whereas PHP is ready to go. So yes it’s more the Rails framework than the Ruby language I dislike, but they are inseparable as far as web development goes.

  5. mark says:

    And here’s a perfect example of why RoR is awful… a really obvious thing is really hard to do, and the only answers are “yeah it’s a pain”, “hack around it” or my all-time favorite “why would you want to do that anyway?”. This stupid little problem has cost me hours of time trying to resolve properly, and I still haven’t got a solution to it.

    http://stackoverflow.com/questions/4244182/how-to-customize-gemfile-per-developer

    Rail. Is. Shite.

  6. Erik says:

    Is it really MVC that you dont like ?

    • mark says:

      Not really, although I’m not keen on the scaffolding and aforementioned naming assumptions made as part of that.

      My favorite thing about Ruby is the model abstractions of database relations. That’s good, useful stuff. The rest, blah. When I see something like “items_path” in any other language I can do a keyword search and find out where it’s defined. In RoR I just have to “know” that it will be a made into a method on the fly according to some over-eager convention. I don’t think it’s ridiculously old-school for me to want something that looks like an identifier to be either defined or undefined.

      And the pluralization isn’t even consistent. Why do I have an “items_controller” and a table called “items” and yet the model is always singular even in the case of “Item.all” ?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>