# HAML makes me love and hate Python

**URL:** <https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537>\
**Category:** Rails\
**Created:** [January 19, 2008, 5:33am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537 "2008-01-19T05:33:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [January 19, 2008, 5:33am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/1 "2008-01-19T05:33:51Z")

</div>

I’m just a rails newbie, but I thought I would point out a small  
observation.

About a year ago, I was having real trouble making the decision about  
whether I should learn Ruby or Python. I finally settled on Ruby, one  
of the reasons being that I didn’t want my language to tell me how  
whitespace should work. (Although the main reason was how object  
oriented Ruby is)

Although I’ve never really used Python, I now love it with all my  
heart thanks to HAML, lol. The whole whitespace thing is amazing in  
HAML. It is infinitely superior to regular HTML. It’s so much cleaner,  
easier to read, easy to write. It’s just amazing. I can’t believe I  
actually have to write “end” after all of my Ruby blocks. I’m almost  
tempted to write Ruby in HAML so I don’t have to do that, lol.

It makes me think that perhaps I misjudged Python, or too quickly  
dismissed its use of whitespace.

Now, to the flip side of the coin.

I hate HAML with a passion. I can’t stand it. The god damn whitespace  
makes it almost impossible to edit. Although it’s easy to write, if  
you ever make any changes, or want to copy and paste anything, it’s i-  
m-p-o-s-s-i-b-l-e. If you make one change, you may have to re-indent  
your entire file. Oh my god, I hate it so much.

I couldn’t imagine writing an entire program in such a manner. How do  
Python people stand it? Do they just have good editors? We could  
really use a HAML editor, I think.

Okay, I’m done with my rants. Oh, and the whitespace thing isn’t  
enough to make me go back to HTML. I will never write HTML again.

Philip

---

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [January 19, 2008, 5:56am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/2 "2008-01-19T05:56:03Z")

</div>

On Jan 18, 2008, at 10:33 PM, Stedwick wrote:

> I’m just a rails newbie, but I thought I would point out a small  
> observation.

> Okay, I’m done with my rants. Oh, and the whitespace thing isn’t  
> enough to make me go back to HTML. I will never write HTML again.
> 
> Philip

It’s funny you rant this way. I have been thinking about HAML and  
how much I’d like to use it, but I’ve got this thing about  
indentation. As long as I’ve been programming, roughly 13 years,  
I’ve preferred 4 space tabs over everything else. I’ve tried 2  
spaces, 2 space tabs, 4 spaces, and a few other odd configurations,  
but I always come back to 4 space tabs. So I won’t even try HAML if  
it _forces_ me to use 2 spaces. I have, however, wondered if I could  
hack it to accept tabs. I just don’t know if I’m talented enough to  
do that.

_sigh_

That’s the problem with being stubborn: I’d rather spend more time  
than necessary doing something because I’m set in my ways. You know  
what some people say about old dogs that can’t be taught new  
tricks…eventually they get shot.

Peace,  
Phillip

---

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [January 19, 2008, 5:57am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/3 "2008-01-19T05:57:14Z")

</div>

On Jan 18, 2008, at 10:33 PM, Stedwick wrote:

> Although I’ve never really used Python, I now love it with all my  
> heart thanks to HAML
> 
> Now, to the flip side of the coin.
> 
> I hate HAML with a passion. I can’t stand it.

Neapolitan ice cream must really drive you crazy. 😉

---

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [January 19, 2008, 6:30am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/4 "2008-01-19T06:30:32Z")

</div>

It occurs to me to include the HAML that I just wrote that spawned  
this rant, just in case anyone’s curious. It runs this page  
[http://brocoum.com/voter/startrekvoyager/episodes](http://brocoum.com/voter/startrekvoyager/episodes) that allows people  
to vote on their favorite Star Trek: Voyager episodes.

- if @category.items.size \> 0  
%table.sortable  
%thead  
%tr  
%th.sortfirstasc.number Net Votes  
- for header in @category.headers.split(‘::’)  
%th.text= header  
%th.nosort= “?”  
%th{:class =\> “nosort”, :style =\> “width: 100px;”} Cast Vote  
%tbody  
- for item in @category.items  
%tr  
%td  
%div{:class =\> “netVotes”, :id =\> “netVotes\_#{item.id}”}=  
item.net\_votes  
- for field in item.fields.split(‘::’)  
%td= field  
%td  
- if item.tooltip  
- tooltip(:id =\> item.id) do  
= item.tooltip  
%td  
- unless item.votes.find\_by\_ip\_address(request.remote\_ip)  
%div{:id =\> “promoteDemote\_#{item.id}”}  
- form\_remote\_tag(:url =\> {:controller  
=\> :items, :action =\> :vote, :id =\> item, :value =\> 1}, :before =\>  
“beforeVote(#{item.id})”, :after =\> “afterVote(#{item.id}, 1)”) do  
= submit\_tag “+”, :class =\> “promoteDemote promote”  
- form\_remote\_tag(:url =\> {:controller  
=\> :items, :action =\> :vote, :id =\> item, :value =\> -1}, :before =\>  
“beforeVote(#{item.id})”, :after =\> “afterVote(#{item.id}, -1)”) do  
= submit\_tag “-”, :class =\> “promoteDemote demote”
- else  
This category is empty.

Also, I do like Neapolitan ice cream, but only because I love ice  
cream in general 🙂

---

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [October 26, 2008, 3:31am UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/5 "2008-10-26T03:31:03Z")

</div>

Philip B. wrote:

> I couldn’t imagine writing an entire program in such a manner. How do  
> Python people stand it? Do they just have good editors?

Having a good editor is critical if you do this stuff for a living. In  
case someone else stumbles on this post;

Vi:

- go to start of line that you want to indent/outdent
- hit shift+v
- go down to the last line you want to indent/outdent
- hit \< to outdent hit \> to indent

Textmate:

- go to start of line that you want to indent/outdent
- hold down shift and move to the last line you want to indent/outdent
- hit cmd+[to outdent, cmd+] to indent

Emacs:

- go to start of line that you want to indent/outdent
- hit ctrl+space
- go down to the last line you want to indent/outdent
- hit ctrl+ where is the number of spaces you want to  
indent/outdent
- hit ctrl+x 

2/3 editors are cross-platform, so you should be all set regardless of  
your OS.

-berto.

---

<div class="post-metadata">

**Author:** ![stedwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90ced4/32.png) [@stedwick](https://www.ruby-forum.com/u/stedwick)\
**Post date:** [January 19, 2008, 4:54pm UTC](https://www.ruby-forum.com/t/haml-makes-me-love-and-hate-python/126537/6 "2008-01-19T16:54:36Z")

</div>

I absolutely love Haml too, we’re converting everything over and it’s  
so much cleaner.

I do hear you regarding the making modifications issue, that bugs me  
too at times. I think it is mostly an editor issue and while a  
dedicated Haml editor would be great I think it could probably be  
solved with some Haml bundle support in popular editors.

While I don’t think they handle auto-indentation when changing files,  
I know there are bundles for textmate and netbeans.
