Skip to content

Comment on HAML: the unforgivable sin

Comments

I don't have anything against HAML, and actually think the syntax is alright. Even gave it a spin some smaller codebases. But I have a hard time finding reasons to switch to it. Until I find a compelling reason to use it, HTML works fine for me.

Most arguments I see seem to primarily argue around ascetics. I'd welcome anyone to post their thoughts to help me sway my position.

To the author's credit, I immediately recognize the benefits of SASS and CoffeeScript.

One way I have found HAML functionally useful is that it was easier to move code around the page. There are fewer lines to move, so it’s easier to remember exactly what you’re moving, and I don’t have to worry about forgetting to move the closing tag. You do have to re-indent after you move the lines, but you would do that anyway with plain HTML. I did a lot of moving code around the page when I implemented Photoshop designs, and I was thankful for that aspect of HAML.

I also used the embedded-Ruby feature to DRY-ly have variations on a page prototype. I was able to switch between four different versions of the page by changing just one variable at the top – I used case statements and a few Ruby helpers on the page to enable the appropriate sections and CSS classes of that version. That was for a static page not linked to any web framework – it was nice to be able to use code without having to set up a huge framework. It could have been messy mixing Ruby code with HTML in the same file, but since this was just a small one-off page, it wasn’t a problem.

I felt the same as you, until I actually decided I'd try it in a project just as an experiment. I will now never go back. Looking at it, "meh"; actually using it, "awesome!".

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.