The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Thoughts on Haml

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Britt

Posts: 1319
Nickname: jamesbritt
Registered: Apr, 2003

James Britt is a principal in 30 Second Rule, and runs ruby-doc.org and rubyxml.com
Thoughts on Haml Posted: Apr 29, 2009 9:28 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by James Britt.
Original Post: Thoughts on Haml
Feed Title: James Britt: Ruby Development
Feed URL: http://feeds.feedburner.com/JamesBritt-Home
Feed Description: James Britt: Playing with better toys
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by James Britt
Latest Posts From James Britt: Ruby Development

Advertisement

Every so often I get prompted (more or less) for my thoughts on Haml. Someone suggested I write them up.

I’m not a fan. Some vocal number of people are big Haml enthusiasts, and while I think I get what they see as its virtues, it just doesn’t work for me.

In no particular order, here’s what irks me.

I already know HTML. I have no trouble reading it, no trouble writing or editing it. I have an editor, vim, that makes working with HTML fairly simple. I’ve no compelling reason to learn another syntax in order to end up with markup that’s already easy to write. (BTW, if you are not using an editor with auto-tag completion and other HTML/XML helpers you are making a mistake). I get the impression that many Haml fans are programmers who don’t already know (or are not comfortable with) HTML, so they have a learning curve no matter what, and Haml may be less onerous than HTML. Me, I’m not afraid of HTML or XML, and I find Haml Perlishly cryptic.

It seems to grab the worst features of Python and Perl: Magic indentation and write-only syntax. No, I’m not interested in debating the merits of either. I view static indentation as I do most forms of static typing: needlessly restricting in an attempt to solve problems that don’t come up much in Real Life code but make for nice pedantic rants about “But what if?”. I also know that one man’s cryptic is another man’s poetry. Much poetry is an acquired taste, and often bad.

I have a hard time navigating Haml documents. With HTML I can easily jump from the start or end tag of a element to the matching one. This is quite handy when I want to insert something at the end of an element; from the start tag, hit %, and jump to the end tag. Perhaps this is also possible in Haml, but I’ve not figured it out. Instead, in Haml, I do the Dance of Matching Indentation, and sadness follows.

It seems that whenever I see examples of Haml (or Yaml, for that matter), they are pretty short. That’s because the allure of magic indentation wears thin for large docs. (Cute anecdotal tale that preaches to the choir: I made this observation about Python code to a Python fan, and was told that it worked to ensure you kept your methods short. That was the first and only time I was told that the white-space tax had a punitive purpose.)

I can hit some keys in vim and auto-format my HTML docs. I can easily cut and paste chunks of markup and move them around, and have my editor handle the formatting. Not so with Haml, where there is constant risk of offending the gods of The True Indentation.

I often work with Web designers who will send me HTML pages that need to be re-worked into templates. Having to covert that into some other format just so I can get HTML in the end is dopey.

I like HTML over XHTML. See http://hixie.ch/advocacy/xhtml (though the suggestion to use the still “Working Draft” HTML5 is somewhat puzzling).

I’m sure I could do something clever and make sure I send my pages using the application/xhtml+xml MIME type, but I don’t. I don’t see the benefit when I can use HTML 4 and the default Web server configuration. It Just Works FTW.

I used to use XHTML, largely because I could more easily check my Web pages using an XML parser and XPath. But tools such as WWW::Mechanize have become really good at handling HTML 4, so the charm of XML has faded.

Just for gits and shiggles I spied on the headers exchanged when fetching http://haml.hamptoncatlin.com

My browser sends this (indicating that it will accept assorted XHTML-friendly MIME types)

    GET / HTTP/1.1
    Host: haml.hamptoncatlin.com
    User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080419 Ubuntu/8.04 (hardy) Firefox/2.0.0.14
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: UTF-8,*
    Keep-Alive: 300
    Connection: keep-alive
    Referer: http://www.google.com/search?q=Haml&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a
    Cache-Control: max-age=0

It gets back this:

    HTTP/1.x 200 OK
    Date: Sun, 22 Mar 2009 01:34:55 GMT
    Status: 200 OK
    Server: Mongrel 1.1.5
    Content-Type: text/html
    Content-Length: 4734

... followed by an XHTML file.

I don’t mean to single out the Haml site. This is quite common. If you’re going to go the XHTML path, though, consider doing it in earnest, or it comes off as posturing.

That’s basically it. For those who like Haml, more power to you, just please don’t hand it to me to work with.

If you think I’m wrong on any of my points, please drop me a line with some specific, factual, technical information.

Read: Thoughts on Haml

Topic: ar_mailer 1.3.2 Previous Topic   Next Topic Topic: 'function' in JavaScript - operator vs statement

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use