Stick with ERB or move to Haml

haml.jpg Haml is gaining popularity in Rails community. It claims higher productivity compared to defacto ERB templating. Not everybody agrees though. I see 2 short-term problem with haml.

  1. ERB is similar to it pre-decessor and hence easier to learn. Compared to JSP etc. ERB is similar, you still see lots of HTML tag with interleaved ruby (or Java). Although verbose, it is closer to how your HTML would finally look like.
  2. If your team has a dedicated HTML programmer (Designer as we may call them). These folks are very good at plain HTML and don't want the trouble of converting files and having all the plumbing around when working. It is not efficient for them.

Despite this, I see Haml as valid alternative for following reasons:

  • Its been 2 days since I started using Haml. Obviously, I have yet to higher gain productivity but tools like html2haml help a lot with the transition. I am beginning to see that I am not far behind, in terms of productivity, compared to ERb already.
  • Especially if you don't have a dedicated Designer/HTML programmer on your team, haml gives you another shot at productivity.
  • I am not sure if this is a good idea but you can have both on the same project, but it sure does work. In fact, you can even have layouts, partials and your main page in different templating engine. Atleast, it lowers the barrier to get started.
  • Haml gets ugly when there is too much html nesting. This is a good thing since it encourages breaking your view into partials and making it modular.
  • Haml also promotes better view design by making divs/ids/classes most concise. If you are still using tables a lot, you may find yourself using divs with haml.

Try it out. It's not that bad.

Enjoy!

Related posts:

  1. Bridging the Gap Between Rails Developers and HTML Designers
  2. Adopt a non-techie. Help your business team move faster
  3. Helpers and Partials
  4. Pretty Blocks in Rails Views
  5. From JSP to Ruby on Rails: First thoughts on front-end coding conventions

Topics: , , ,

Comments: 4 so far

  1. In company where I work is some dualism as you write. Programmers mostly like HAML and prefer it over Erb. But our HTML designers (all magic in presentation layer) prefer Erb. They said that Erb is more readable for them, and has syntax highlight in their editors (!).

    Comment by Seban, Thursday, June 4, 2009 @ 1:53 am

  2. As a designer, I love HAML, cleaner, makes sense, and all around a joy to write. If you write HTML and are unwilling to learn HAML, your just limiting yourself to what you know. I only wish HTML 5 would use HAML style syntax :D

    Comment by Stephen Korecky, Wednesday, June 10, 2009 @ 7:21 am

  3. @Stephen, thanks for the comments. I rec’d several comments about designers actually liking Haml. This also makes sense.. once you get used to new format and it is efficient, why look the other way. I am wondering if haml gem has builtin support for making the compile/conversion process easier.. (something similar to “compass –watch” that). Do you mind blogging about how u use haml in ur daily work? This could be something I and designers at my company and others benefit from. Thanks again.

    Comment by Sharad Jain, Thursday, June 11, 2009 @ 8:33 am

  4. Here are a few of my beefs with HAML.

    First, why abstract something that isn’t complex to begin with? I can understand abstracting complex programming languages, but HTML isn’t a programming language and isn’t complex, so why mess with it. I just don’t get it.

    I also disagree that HAML is cleaner. Do you end up using fewer characters? Sure, but that doesn’t translate to it being cleaner. I would argue that my markup is as clean as it’s HAML abstraction any day. And guess what, another front-end developer can read it without knowing HAML.

    Furthermore, I don’t always work in Rails, most of the time I’m writing my markup locally, translating a design comp into XHTML. Why then would I want to rewrite it in HAML? Seems like extra effort, not a reduction in effort.

    Don’t get me wrong, it’s not that I don’t like HAML, I simply fail to see benefits as others do.

    Comment by Darin Burris, Tuesday, August 4, 2009 @ 2:02 pm

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com