Daniel Morrison

Sorry Haml, you won't take over the world.

This passage from Smashing Magazine surprised me:

…recent versions of Rails let you take your pick of templating languages, and nowadays the Ruby interwebs have been all abuzz about an alternative system called Haml.

While I think Haml is very interesting and well done, the big secret is that it will never be mainstream.

Why? One simple reason: HTML is easier. Now I know lots of developers will say No way! HTML is verbose, confusing and hard to read or Haml is so much cleaner and quicker to write. Both of these are true, but everyone already knows HTML.

Everyone. Any kid who’s edited their blog template or MySpace page knows the basics of HTML. They might not know the best-practices, but they understand it. Haml might be cleaner and easier for the programmer brain, but HTML is universal.

Markup vs. Programming

This isn’t a case of lower level languages (assembly) being replaced by higher-level languages (C, etc.), but there’s a temptation to make that comparison. C code is effectively transformed into assembly code in the same way Haml is transformed into HTML. But markup languages are not programming languages.

Let me repeat that: markup languages are not programming languages.

A markup language isn’t meant to be translated from high to low level. I’m writing this in the Textile markup language, but it’s really nothing more than macros to help me write HTML quicker. HTML is the canonical format of this post.

In the same way, Haml is effectively a set of macros. Contrast this to other templating languages (see any blog or CMS). A templating language doesn’t try to reinvent HTML, rather it helps you write more HTML by interspersing programming. In the end, it’s all HTML.

Haml is harder

Why do I think Haml won’t ever be big? Because it’s too different. While all the templating languages vary a bit, they are all readable to anyone who knows HTML. Haml is readable to Ruby users, and that’s about it.

I won’t argue that Haml is cleaner, more concise or easier to code. The problem is that HTML is universal. Your Rails team might be quicker in Haml, but you’ve made your code less maintainable to others and less readable to the masses. Most designers are going to understand HTML even if they don’t write much of it.

I don’t want to say you shouldn’t use Haml or that it is bad in any way. Just realize that there are trade-offs to using a markup language that pretends to be a programming language. You may not like HTML or angle brackets, but they’re here to stay. It’ll take a sea change to get us off HTML, not a new way to write it.


  1. fatcow — March 20, 2009

    Hi Daniel,

    What do you think of markaby?


  2. Daniel Morrison — April 13, 2009

    fatcow: I feel the same way about markaby. I love the concept, but I think its solving the wrong problem, and the bulk of the world will never understand it.

    Use it if it works for you, but I can’t recommend it for most people.

  3. Eduardo Monnott — July 28, 2011

    I think it’s all about ease of maintenace.

    Imagine you have to change a bit of code within a big document. I’d rather prefer diving into a big HAML document than to dive into a big HTML document. I’ll spot the thing I need to change far more quickly in HAML.

    Seriously, I think web languages like HTML and CSS are not meant for coding manually but rather they’re meant to be spat out by server side scripting langs like PHP.

    Look, I’m writing a small static website with just 5 small pages (header, nav, content) using plain HTML/CSS because I thought it would be easy and straightforward. But then I found myself replicating and doing copy/paste many, many,… MANY times…
    not just in my HTMLs but the several CSS’s I have.

    If you’re a programmer, you know thats NOT the right way to do things, it’s so error prone and time consuming even to do little changes.

    I dont understand why isn’t there any standard include feature for HTML so I dont have to copy/paste chunks of code every time I make a change. I mean, it must be present in all web servers and not only in Apache, cause I won’t use Apache.

    So, after this, I won’t ever write a static website using plain HTML/CSS. I’d rather pick something like PHP to make my markup and styles more maintainable and easy to change.

  4. Kristian Jones — November 12, 2011

    I haven’t used HAML however I’ve seen examples of it when I’m sniffing around Ruby.

    I’m a PHP developer with no experience of Ruby (will change sooner or later) and when I looked at HAML I wanted to run away.

    I think HAML over complicates things, there are special things in the HTML source I need to manually insert (not sure how to do it in HAML) e.g. a “rel” attribute and

    among loads of other things.

    The best template engine I have come across is Twig; which is used in the Symfony PHP framework. Not sure if Ruby has a equivalent of this but I think Twig should be the standard of a template engine.

  5. cash advances — August 09, 2012

    http://quickfastcashadvanceonlineloans.us/#578074 – fast cash loans , cash advances – http://quickfastcashadvanceonlineloans.us/#681408 fast cash loans