.rhtml vs .erb

post_update <<-EOF
Can the people who read this rant please remember that this is not a very serious blog. In fact it’s mostly just me talking shit and this post is a prime example. I actually like the changes I’m dissing below, it’s nothing but a rant for rant’s sake and I have no idea why Google seems to be sending so many people to it – so don’t get all upset and leave nasty comments telling me I’m an idiot.

This is a personal blog of the most whimsical and useless kind, and I make no pretensions otherwise. Bear that in mind. Thanks! :-)
EOF

Can someone please tell me what the point of moving from .rhtml to .html.erb is?

I mean seriously. There wasn’t a naming conflict, .rhtml isn’t the nicest extension on earth but it was pretty unambiguous as to what it was – ruby mixed with HTML.

.html.erb is if anything worse. What kind of a file has TWO extensions? Hell, why not have fucking ten. I sometimes like to put CSS and JS into my files as well, they’re feeling a bit left out – I guess that according to this new “all inclusive” philosophy they’re properly named index.html.css.js.erb.

And what the fuck does ERB even stand for? Embedded Ruby, right? Well that would be great if Ruby was two words. One acronym per word is the English standard. Yet another example of Rails flaunting the standards.

I just don’t see the point. Trying to enforce a taxonomy on what are by nature highly mixed and variable files is an exercise in futility. And furthermore, the .erb is completely superfluous within the already highly structured folder structure of a Rails app. What the hell else would it be?

Change for change’s sake. DHH is drunk on power!

Tags: , ,

16 Responses to “.rhtml vs .erb”

  1. bryan Says:

    I agree totally, it seems pointless. Looking at a lot of changes to Rails for 2.0, I have to say the majority of them look pretty weak. The changes for fixtures make sense and sound useful, but I’m still wading though the rest of the mods that seem like one kid just said, “gosh, it’d be nice if I could type 20 chars to make that happen instead of 40.” I’m all for smaller code and whatnot, but most of these just seem silly.

  2. Sho Says:

    [..] like one kid just said, “gosh, it’d be nice if I could type 20 chars to make that happen instead of 40.”

    Thanks for the comment Bryan, couldn’t have put it better myself. I am liking the direction Rails seems to be going in less and less.

  3. Chu Yeow Says:

    Well, actually there is a reason behind that change. That format is actually action.format.renderer.

    So you can do stuff like index.atom.builder and edit.iphone.haml as well. http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done has more.

  4. Sho Says:

    Yeah, it’s logical enough I guess. I do prefer the new format, it’s less ambiguous.

    However, it should have been done like that from the beginning or not at all. Rails is supposed to be “opinionated”, right? So what’s all this renaming to accommodate third-party renderers?

    Unless the renderers are actually going to conflict, having a separate file extension for each one is unnecessary! But that said, I do appreciate the change and am adopting the convention for new files.

    By the way, Chu, thanks for your comments and please bear in mind that this blog is nothing but a personal rant space for me, never too serious ; )

  5. Sho Says:

    And let me just add how annoying it is that one could ever even think about needing a file called “edit.iphone.haml”. So much for “standards” …

  6. Martin Krpan Says:

    Ok, if naming of the files is so damn important, than I wonder, what kind of tool is ROR to attract people that are even considering to take a keyboard and write such a rant.

    This rant is as pointless as the change itself, as the change itself was not worthy of ranting in the first place.

    Here’s the meta – meta rant (very ruby way).

  7. Sho Says:

    Actually, to be honest I’ve kind of come around to the change. It is, indeed, more useful.

    The rant was pretty pointless, but since pointlessness is the very essence of blogging, I think it’s appropriate.

  8. Zoran Rilak Says:

    >> What kind of a file has TWO extensions?

    .tar.gz and .tar.bz2 come to mind. If you think of the extension as a hint to the file’s contents, then it begins to make sense: you are describing the contents of the file from less specific to more specific. Going back from the last extension, you can apply whatever transformations are necessary to get to the underlying format, peel off the last extension, then repeat until you have no extensions left (in the “ideal” case where file name sans extension is the “title”, or “name”, or whatever semantics you wish to assign depending on the final application that handles the file).

    Observe: archive.tar.gz -> gunzip to archive.tar -> untar “archive”, by common consent into ./archive directory.
    Similarly: page.html.erb -> process with ERB -> page.html -> render “page”.

  9. Sumit Says:

    I was going to mention the tar.gz / tar.bz2 but Zoran beat me to it. I do enjoy a good rant though, and yours was a good one.

    My relationship with Rails has been very love/hate over the past year or so. My professional website is in rails, my personal site is still in PHP. I like Rails as an engine but the documentation is horrible and things like “rails engines” should have been built into the core as when I first saw rails, bundling applications the way engines did seems to be something the framework was lacking. They should really have multiple /app directories so you can glue together and reuse components.

    There aren’t as many pre-made things out there for Rails. You can find almost everything for PHP: auto-generating event calenders, guestbooks, etc…tons of things you can just drop into a website with just a little modification. Rails is a new comer so a lot of that stuff you have to end up writing yourself.

    But what gets me for Rails is the documentation. It sucks, really bad. I have trouble navigating that API. What makes PHP and Java so great are their docs. I program in C# in Linux (using Mono) and occasionally even in windows and on both platforms, the biggest problem is finding good documentation and examples.

    Rails 2.0 also broke a lot of stuff. I don’t really have a prob with that as PHP5 breaks a lot of things with 4, I just wish my web host had told everyone before upgrading. :) But what I dislike most about 2.0, all the documentation out there still references 1.0. Things like migrations, pagination….all that stuff needs to have extensive docs and upgrade paths. I still can’t find anything on how to specify the length of a string in the new migrations online.

    Rails is a nice idea in concept, but people are so hard core about it that it’s really a shame, cause it’s not the end-all framework, not even close. It’s just a good start.

  10. Sho Says:

    Sumit: Yeah, that’s basically exactly how I feel too.

    I don’t like PHP and I generally don’t like the “copy and paste” mentality. But Rails is very immature and the documentation is *shocking*. Just 2 days I had a lengthy conversation with a fellow developer in an attempt to find the best, most “official” way to turn off logger at the controller level. I’d heard def logger nil end somewhere, but needless to say it’s not in the docs and it took an hour or more to get it all tested and confirmed. Oh, and for some reason it varied between our computers. Unbelievable.

    Don’t get me wrong, I also love Rails and the promise it seems to hold for web development in the future. But it could do a lot of things are lot better. They may as well just take down the api and “manuals” site, they are worse than useless – they are actually misleading.

    Like you said, Rails is a good start. But I don’t expect to be using it in 5 or even 3 years time. Ruby, on the other hand, I’m going to use for as long as possible : )

  11. Jarrod Says:

    Because with this convention you can have

    .html.erb
    .js.erb
    .xml.erb
    .json.erb
    .myownextention.erb

    they are all presentation templates (read: erb templates) so should all end with .erb.

  12. Sho Says:

    Thanks Jarrod, I know. I am using .xml.erb and .css.erb myself. As I’ve mentioned I like this change a lot and this pointless rant is just that.

    I’ve added a comment to the top of the post stating as much, hopefully people will stop taking it seriously and stopping to explain it to me.

    I tend to think people who post things and then take them down are kind of cowardly so I’m leaving it up but please, dear readers, no more comments “explaining” the change to me – I KNOW.

    I can’t even remember why I wrote it. Maybe I was annoyed halfway through renaming all my files or something. Who knows. But just .. no more serious comments setting me straight, OK? Thanks! ^_^

  13. Ryan Says:

    You don’t have to rename all of your files…that would be enough to make me go insane (or, more insane than I already am :D ).

  14. Jason Says:

    Sho… Count me among those who fully understand the change but feel like DHH should get a swift kick in the scrote for introducing it anyway. html.erb.html.rb.bff.omg.lol for the epic lose.

    In other news, Rails 2.0 introduces some incredibly positive changes yet (as so many have pointed out) has miserable documentation. Rant on, my friend! Rant on!

  15. fred mailer Says:

    Has anyone every wondered why we even bother with all of this. Life is out there right?? not in here. not in front of this screen. this giberish. whatever

  16. Devin Says:

    .rhtml vs .html.erb

    as far as the above is concerned… I just don’t care. I try to follow what the standard tells me, now if it works as .rhtml, then heck i’m not going to find/fix everything, i’ll just modify my development going forward.

    rails 2.2.2+ issues

    ok, again i was annoyed at first, but the new features make sense. The Ruby/Rails core developers are the type of people I’d love to play chess against, (ie. they probably could kick my ass!). Eitherway, these guys/girls may have opinions, but I usually come around to agreeing (or seeing the line). Like a really good chess move.

    But everyone eventually makes a blunder or two…

Leave a Reply