So why do I bang my head against my desk every time I see someone using it in a view?
Indentation Sucks (Usually)
Notice the cute little parenthetical up there? That’s because I really do like CoffeeScript, which is just as whitespace-sensitive as Haml. So what’s the difference?
}) sequences. Closing arguments and functions again and again is not only a headache, it happens so frequently that some sort of error is inevitable. Strict whitespace rules help us avoid errors in closure. Of course, the same argument can be made about HTML and Haml’s whitespace rules, but there’s another key difference here.
HTML closures indicate which tag they close. You don’t have a forest of
)})})}, which even if you indent correctly still won’t tell you which parenthesis or bracket they’re closing. Instead you have an obvious and syntactic declaration of which tag you’re ending when you end it. You can argue that the tag closure is unnecessary (Haml seems largely based on this argument), but you’re trading explicit tag closure for explicit whitespace restrictions…
And ultimately (and most damningly), whitespace restrictions make the document harder to read and understand than closing tags. If you have an extremely long page with many nested elements, Haml is very difficult to comprehend and consequently much harder to use.
If It Ain’t Broke…
SASS and CoffeeScript fix serious errors and oversights in the implementations of their specific languages. CoffeeScript ensures correct lexical scoping of variables; SASS allows variable assignment and better selectors than CSS. Both are enormous improvements on the languages they compile into.
Haml doesn’t add anything at all to HTML. There’s no special Haml tags that do something HTML couldn’t do by itself. It gives you a shortcut for the syntax, but that’s essentially it.
And HTML really isn’t that bad by itself. The syntax is already fairly clean and clear; it’s not like we’re lost in a field of, well, parenthesis and curly brackets. Tables can get a little muddy at times, but good HTML and CSS prevent documents from becoming unreadable – and Haml doesn’t offer any interesting or unique tools to improve readability, either.
Designers Aren’t Programmers
Sure, you can change that HTML to Haml. But let me guarantee you, one day they’ll want to change something, and at that point you do one of three things:
- Show them the Haml site, tell them to do it all in Haml, and pay for them learning it.
- Take their design and convert it to Haml yourself and then incorporate it into the page.
- Curse your unjust fate and just switch to erb and copypaste their changes in.