HAML makes me love and hate Python

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

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

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. :wink:

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 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 :slight_smile:

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.

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.