Why I don’t use HAML or SASS

Seeing as the ERB vs HAML decision has now reached the armed conflict status, I figured that I would voice my opinions before it becomes yet another holy war.

HAML, SASS, and ERB are all tools. From what I’ve seen, they are all very good quality and they all have their shortcomings. You can write “brief elegant code” and “horrible spaghetti code that should never see the light of day” in them all.

But I choose ERB for all of my projects and anything I open source:

  1. The #1 reason I use ERB is because 99% of the development I do is with existing code base in ERB. Sure, ERB and HAML can be mixed but that’s not a road I want to go down. I’ve already tried to mix Test::Unit and RSpec in a few projects and it’s not maintainable at all (Test::Unit in the core code, RSpec in the plugins).
  2. Even in a brand new project, I will not use HAML if that project is going to be open source. Since ERB comes with Ruby and Rails, there is no additional requirement to getting it installed and setup. HAML and SASS both need additional gems installed in order to work. For Rails developers this might be easy but how “easy” would this be to explain to a non Rails developer who wants to use your software? Could you explain how to install HAML and SASS to your great Aunt Tillie?
  3. I’ve personally found that SASS doesn’t play well with several deployment environments. Having to compile your CSS when deploying is yet another barrier to getting your software setup. I was also surprised at how many Rails applications are deployed to a environment with a read only public directory. This is not just on Heroku, it’s also in many enterprise IT shops.

That said, HAML and SASS both have a lot of good ideas. I’ve only worked on trivial HAML applications but the views does look cleaner than ERB. I’d think that in more complex applications, HAML could get just as messy as ERB though. I also really like how SASS lets you add some dynamic bits to your CSS. I haven’t found a really elegant solution to this yet using ERB, other than dumping inline CSS for the dynamic bits.

Like any opinions, I reserve the right to change this one at any time. But I will need something to change before that will happen. Maybe I just need someone to show me the ropes with HAML and SASS.

And if HAML, SASS, or ERB are working great for you, then keep using them and make them better.

9 comments

  1. Anonymous says:

    1. erb->haml conversion is mostly automatic. manual fixups are quite easy so converting even a big codebase can be done quite fast.

    2. I didn’t see any rails project that didn’t use at least some gems. so adding yet another does no harm. besides, you can always freeze your gems into your project. => non issue.

    3. calling a rake task a barrier is overstatement :). and really not a valid excuse not to use a tool which saves you time.

    It looks like you just didn’t ‘get’ haml, or you would find ways to use it instead of finding excuses not to :)

    • edavis10 says:

      1. An automatic conversion might work but it still will require a lot of cleanup. That’s time and energy that could be used to build the software

      2. That’s yet another gem that has to be code reviewed, managed, installed, bundled.

      3. That’s a stretch. Yes it could be automated but who’s to say that it would save time? When I used HAML I was about a quarter of the speed as I am in ERB (5 years experience in ERB). If I used HAML for 5 years, would I be faster? No one knows but you can’t jump to that conclusion.

      Regarding “getting HAML”: sure maybe I don’t but that doesn’t mean the experiences I’ve had while trying to use it are any less valid.

      • Nico says:

        I bet within a short period time you would love haml and would not like to go back to clunky erb anymore – well, at least that happened to me ;-)

          • Anonymous says:

            Regarding point 3 – I used to be a decent Java/PHP programmer. Then I discovered ruby. Even if I wasn’t so experienced at the beginig, I could feel that it was an improvement. The same happened with erb & haml. I just don’t want to do erb any more now.

  2. Josh says:

    > I also really like how SASS lets you add some dynamic bits to
    > your CSS. I haven’t found a really elegant solution to this yet
    > using ERB, other than dumping inline CSS for the dynamic bits.

    How about LESS? http://lesscss.org/

  3. ian eyberg says:

    I am becoming increasingly disappointed with erb/haml and other templating languages regardless — the speed issues with each of them are completely ridiculous — you can cache your sql and you can cache views but passing all of your templating through a rendering engine really DOES hit your performance hardcore — it really is quite easy to test this as well — just open up a new merb/rails/sinatra app and do ‘hello world’ in erb/haml then do it as a string from your controller/action pair — or do something a little more with markup in it — you will see what I mean — I don’t have a good solution to this as of yet but I am not about to drink more kool-aid either

  4. Guest says:

    I don’t use Haml for two reasons. One is entirely personal: I don’t like any language with semantic spacing as they introduce the opportunity for hard to see (literally) bugs and it’s difficult to move code around. The second one is practical: web designers don’t work with Haml, they work with HTML. I can install Rails and git on their computers and make them work on ERB files because they closely resemble HTML. They can fix HTML and CSS without support from developers. With Haml a designer would work on HTML and a developer would translate it into Haml. When a designer changes the HTML s/he would send HTML to a developer which would have to find out the changes and match them to the Haml code. That’s too slow, too error prone and it would cost too much at the end of the day. I understand that developers create HTML from JPEGs in some projects. Haml is good in those cases but they are very unlucky projects. A good web designer that can do HTML and CSS is a bless for a development team.

    • Your answer may be old but I’ll reply anyway.

      Lots of developers and project leaders have this opinion about there designers can’t work whit this.

      Designers are human to and can learn stuff just as an developer can do.

      Don’t know where haml where when this article was written because i did just learn it. But in my opinion its much easier. And for designers i really think they would like it more. classes and ids can be assigned at the same way as they assign them in there css, sass, scss or what ever them use.

Comments are closed.