Poll: Significant Indentation

D

David Masover

I've just re-read the "Beating a Dead Horse" thread. I will bring that up
shortly, but first I want some actual numbers.

I really like Haml. But I really like Erector (inspired by Markaby). The
biggest reason I prefer Haml to Erector is significant indentation.

I'm curious how many people agree with me. A quick poll -- send answers
directly to me, and I'll count and summarize them for the list:



What is your favorite Ruby template language for generating HTML?

Which editor do you use to edit HTML templates?

Which editor do you use to edit Ruby source?

If Ruby had optional significant whitespace as a core language feature (maybe
like http://gist.github.com/117694), would you use it:
- Never?
- Sometimes?
- All the time?
- Don't care?
- Only with different syntax (lazibi, colon, something else?)

If your favorite template language is Haml, would you prefer Erector if Ruby
had significant whitespace?
(yes/no/NA)

If you actually dislike Haml, is it because of the significant whitespace?
(yes/no/NA)

Have you done any significant development in Python?
(yes/no)



That's all.

I welcome opinions, but what I'm after here are either specific, countable
statistics, or a criticism of the questions being asked. I think there will be
a lot more to discuss once we have some numbers.

Also: Should I cross-post this to the Rails group?
 
S

Seebs

What is your favorite Ruby template language for generating HTML?

I've been using erb since that's what's handy in rails.
Which editor do you use to edit HTML templates?
vi

Which editor do you use to edit Ruby source?
vi

If Ruby had optional significant whitespace as a core language feature (maybe
like http://gist.github.com/117694), would you use it:
- Never?
- Sometimes?
- All the time?
- Don't care?
- Only with different syntax (lazibi, colon, something else?)

Never, ever, ever, ever, ever. I would weep for the horror of knowing that
people would send me code which was broken that way.
If your favorite template language is Haml, would you prefer Erector if Ruby
had significant whitespace?
(yes/no/NA)
NA.

If you actually dislike Haml, is it because of the significant whitespace?
(yes/no/NA)

Pretty much.
Have you done any significant development in Python?
(yes/no)

No. I did a little bit, and quit because I couldn't get past the horror
of significant whitespace.

It turns out to be surprisingly error-prone. I'd rather have actual
tokens drive indentation (through tools like indent/cb) than have
spaces break things. If there are tokens for, e.g., blocks, or beginning
and end of grouping, it's reliably possible to figure out what's happening
and to modify the indenting to fit. If you go the other way, you are
totally, completely, screwed if anything goes wrong -- there's neither
information to let you determine what was intended, nor a way to detect
that something else was intended.

-s
 
F

Florian Gilcher

Okay, flame on ;)!
What is your favorite Ruby template language for generating HTML?

ATM, Erector. I have to admit that "template language" is a topic
I hate because I've never seen one that I totally like while not being
able to come up with a better one. I do miss a Ruby version of TAL,
though, just for play.
Which editor do you use to edit HTML templates?

Textmate, VIM
Which editor do you use to edit Ruby source?

Textmate, VIM
If Ruby had optional significant whitespace as a core language
feature (maybe
like http://gist.github.com/117694), would you use it:
- Never?
- Sometimes?
- All the time?
- Don't care?
- Only with different syntax (lazibi, colon, something else?)

Never, such a feature should not be optional. I would not use Code
written
using that feature.
If your favorite template language is Haml, would you prefer Erector
if Ruby
had significant whitespace?
(yes/no/NA)
If you actually dislike Haml, is it because of the significant
whitespace?
(yes/no/NA)

yes, while it is not the only reason.
Have you done any significant development in Python?
(yes/no)

What's significant? I've done my fair share of development in
languages using
the off-side-rule, e.g. Python and Haskell.

yes
That's all.

I welcome opinions, but what I'm after here are either specific,
countable
statistics, or a criticism of the questions being asked. I think
there will be
a lot more to discuss once we have some numbers.

Okay, I tend to ignore this discussion, mostly because I don't think
it is
worth much. It comes up every half a year, fills the mailing list and
is only
beaten by long discussions about ++.

While I'm not explicitly against using the off-side-rule (I like how
Haskell
uses it), I think you should pick one and stick with it. Ruby doesn't.
In the
end, I don't see syntax as that important.
For example, if I'd had to steal something from Python, it would be
guaranteed
Method identity.

I also would prefer a parser for literal Ruby much more than having
significant
whitespace.

Regards,
Florian
 
C

Charles Johnson

On Dec 13, 2009, at 5:07 PM, David Masover wrote:

What is your favorite Ruby template language for generating HTML?

erb


Which editor do you use to edit HTML templates?

textmate/vi

Which editor do you use to edit Ruby source?

textmate


If Ruby had optional significant whitespace as a core language feature
(maybe
like http://gist.github.com/117694), would you use it:
- Never?

Never


If your favorite template language is Haml, would you prefer Erector if
Ruby
had significant whitespace?
(yes/no/NA)

NA


If you actually dislike Haml, is it because of the significant
whitespace?
(yes/no/NA)

Yes


Have you done any significant development in Python?
(yes/no)

No

Cheers--

Charles
 
D

David Masover

Okay, flame on ;)!

Well, if you want...
Never, such a feature should not be optional.

If you mean you hate it so much you don't want to see it, fine.

If you mean you'd like to see it go one way or another, that's interesting.
Parentheses are often optional in Ruby. I think options are good -- coding
conventions should be enforced by the project, not the language.
What's significant?

Mostly looking for self-assessment here. The fact that you can identify
something else you'd want to take from python suggests you've at least used
it. Contrast to Seebs, who "couldn't get past the horror" -- not that it's an
invalid opinion, but I'd much rather hear from people who are comfortable in
both.

For example, I can't get past the horror of PHP or Visual Basic, so my opinion
isn't as valuable as that of someone who has done significant development in
PHP and lived to tell about it.
Okay, I tend to ignore this discussion, mostly because I don't think
it is
worth much. It comes up every half a year, fills the mailing list and
is only
beaten by long discussions about ++.

I agree, which is why I've made it a poll. Mostly, I'm wanting to find out if
it's worth my time to pick an implementation and bring it up to speed, or
organize with other people who like significant indentation.
 
D

David Masover

Since people are replying on-list, I might as well. If you couldn't guess:

What is your favorite Ruby template language for generating HTML?
Haml.

Which editor do you use to edit HTML templates?
Kate.

Which editor do you use to edit Ruby source?
Kate.

If Ruby had optional significant whitespace as a core language feature
(maybe like http://gist.github.com/117694), would you use it:
Sometimes.

If your favorite template language is Haml, would you prefer Erector if
Ruby had significant whitespace?
Yes.

Have you done any significant development in Python?

No.
 
S

Seebs

If you mean you'd like to see it go one way or another, that's interesting.
Parentheses are often optional in Ruby. I think options are good -- coding
conventions should be enforced by the project, not the language.

The problem is that indentation sensitivity isn't optional -- it's
not something you can just not use if you don't want it, because if
it's there, you'll get code that relies on it.
Mostly looking for self-assessment here. The fact that you can identify
something else you'd want to take from python suggests you've at least used
it. Contrast to Seebs, who "couldn't get past the horror" -- not that it's an
invalid opinion, but I'd much rather hear from people who are comfortable in
both.
For example, I can't get past the horror of PHP or Visual Basic, so my opinion
isn't as valuable as that of someone who has done significant development in
PHP and lived to tell about it.

I disagree. I have done significant development in PHP, and your opinion
is PRECISELY correct.

-s
 
F

Florian Gilcher

Well, if you want...

It was more meant as a joke. Remember: pack irony tags next time ;).
If you mean you hate it so much you don't want to see it, fine.

If you mean you'd like to see it go one way or another, that's
interesting.
Parentheses are often optional in Ruby. I think options are good --
coding
conventions should be enforced by the project, not the language.

Yes, and it is one of the issues where there are often collisions while
defining coding standards. The problem is that I believe there should
not
be a too big visual delta between two options.

While options are good (I do have my fair share of strange patterns I
love
to use as well), you can also over-cramp the language with options. As
I wrote,
I would love to see literal Ruby and actually thought about
implementing it.
But on such a scale, that would mean two and a half things:

1. your project is not accepted and a lot of unnecessary work
2a. your idea is accepted into core
2b. you introduce a hard community split - those who install you
library and
those who don't.

Literate Haskell for example only works because GHC understands it.
Mostly looking for self-assessment here. The fact that you can
identify
something else you'd want to take from python suggests you've at
least used
it. Contrast to Seebs, who "couldn't get past the horror" -- not
that it's an
invalid opinion, but I'd much rather hear from people who are
comfortable in
both.

It's not like I am opposed to Python. Most of the time, I just don't
see a reason
to do a lot of work in it, being very proficient in Ruby. They kind of
solve the
same problem. I am in great pain for not being able to visit the RuPy
the last
two years.

I do have some fun with pypy from time to time and would never think of
reimplementing that in Ruby, just because it is written in Python.
For example, I can't get past the horror of PHP or Visual Basic, so
my opinion
isn't as valuable as that of someone who has done significant
development in
PHP and lived to tell about it.

I also did significant work with PHP. PHP 5.3 is... somehow okay as a
language.
The core library is still horrible. And thats kind of my point: I use
Ruby because
I like the way the core and std lib is built. Not because there is an
end-thingy
at the end of my blocks or not. Matz's EuRuKo2009-talk had a nice stab
at the
"API defines the language" thing.

I know quite a share of languages that a lot of people find horribly
ugly. Haskell,
Prolog and Erlang mostly. I don't mind their syntax that much, because
I am more
interested in the runtime system they use. I write Ruby because it
allows some
pretty descriptive concepts and is a good in-between between all those
languages.
Sure, the end-wall at the end of nested class definition can be ugly
from time
to time, but it by far does not make irritate me enough to want a
whole alternative
parser for it.
 
D

David Masover

It was more meant as a joke. Remember: pack irony tags next time ;).

Oh, I got it. The smiley was a dead giveaway, right? :p
If you mean you hate it so much you don't want to see it, fine.

If you mean you'd like to see it go one way or another, that's
interesting.
Parentheses are often optional in Ruby. I think options are good --
coding
conventions should be enforced by the project, not the language.
[snip]
While options are good (I do have my fair share of strange patterns I
love
to use as well), you can also over-cramp the language with options. As
I wrote,
I would love to see literal Ruby and actually thought about
implementing it.
But on such a scale, that would mean two and a half things:

1. your project is not accepted and a lot of unnecessary work

That's the purpose of this poll. If there's no interest, I probably won't
bother.
2a. your idea is accepted into core
2b. you introduce a hard community split - those who install you
library and
those who don't.

I don't see where this is a huge problem. If it really can be a library, there
are either those who adopt it or those who don't. For example, Rails
introduces the .map(&:foo) idea, which eventually made it into core. It also
introduces 5.hours.ago, 2.minutes.from_now, and 'octopus'.pluralize, none of
which will ever make it into core. And it's far from the only library to hack
all over core.

It would be especially non-problematic if it had a tool similar to lazibi, so
that people who absolutely couldn't stand it could convert it back.

But even as it is, we still have a few Lisp people who throw parentheses
around EVERYTHING in Ruby, a few people moving from C and other languages who
find it just weird to define a method without parentheses, even if it won't be
used that way:

def foo(options)
...
end
foo :bar => :baz

And of course, we have people who use define_method and other metaprogramming
techniques, and people who pipe things into eval, and people who store
configuration as Ruby scripts, and people who store it as Yaml, and people who
write their own storage format.

I don't think those who cry out in agony at the mere sight of significant-
indentation code will really have more trouble reading and maintaining it than
I would maintaining lisp-style Ruby.

For that matter, did you know Ruby 1.9 now supports this JSON-like syntax
natively?

{
a: 'b',
c: 5
}
# => {:a=>"b", :c=>5}

The new lambda syntax is cool, too:

-> { puts "I'm a lambda!" }

So I don't think this is an issue -- there are as many ways to write Ruby than
there are other programming languages, and new versions can add new syntax. I
think backwards-compatibility and parser manitainability are much bigger
concerns. That is, if my idea is a complete flop, it shouldn't affect anyone
else.

By the way: This post is a _defense_ for the idea of alternate syntax. I'm not
going to start advocating it again just yet.
 
D

David Masover

The problem is that indentation sensitivity isn't optional -- it's
not something you can just not use if you don't want it, because if
it's there, you'll get code that relies on it.

That is true of any library. It's also true of the Lisp-like syntax I
mentioned before -- the following is valid Ruby:

((def setf(name, value)
(instance_variable_set name, value) end);

(setf :mad:file, (open '/etc/passwd'));
(@file.each_line {|line|
(puts (line.gsub 'foo', 'bar'))});
(@file.close))

And yes, that's probably going to be unmaintainable, even if you did come from
Lisp. The point is, no one's forcing you to maintain it -- even if someone has
written code like this, you can still choose to ignore it, or maybe to brave
it with some automated tools to sort it out.

Even things like spaces or tabs for indentation are again up to the individual
project or coder to set some standards and adhere to them.
I disagree. I have done significant development in PHP, and your opinion
is PRECISELY correct.

That's good to know, but again, your firsthand experience is far more valuable
than my opinion which is mostly formed by reading about PHP, and only ever
trying it for a few hours at a time.
 
B

Brian Candler

David said:
I really like Haml. But I really like Erector (inspired by Markaby).

But which is better? There's only one way to find out. FIGHT!!!
What is your favorite Ruby template language for generating HTML?
HAML

Which editor do you use to edit HTML templates?
joe

Which editor do you use to edit Ruby source?
joe

If Ruby had optional significant whitespace as a core language feature
(maybe
like http://gist.github.com/117694), would you use it

Never in a million years. If I wanted that, I'd be using python.
If your favorite template language is Haml, would you prefer Erector if
Ruby
had significant whitespace?
(yes/no/NA)

NA, since I wouldn't be using ruby.
If you actually dislike Haml, is it because of the significant
whitespace?
(yes/no/NA)

NA. HAML is great.
Have you done any significant development in Python?
(yes/no)

No. But I have in the past done significant development in Occam, which
is also a signficant-indentation language.

SEQ
.. do X
.. do Y
.. do Z

It was bearable when using a folding editor, and that limits your choice
of editor a lot. I ended up writing one.

I agree it does seem paradoxical that one can like indentation for HTML
but dislike it for programming. For me the following are important:

- HTML has the need for balancing end tags, and the annoying </...>
syntax. With Ruby it's just three characters, 'end'

- I find HTML templates are small and don't often need moving around or
commenting out; the occasional indent/outdent I can cope with

- I do write ruby in a consistently indented way, but I like seeing the
'end' rather than the execution path falling off a cliff. That is, loops
and other control structures have a bound shape.

OTOH it doesn't matter to me in HTML, since it's all just content and
nested divs.
 
B

Benoit Daloze

[Note: parts of this message were removed to make it a legal post.]

What is your favorite Ruby template language for generating HTML?

Which editor do you use to edit HTML templates?

Well, I'm not using regularly HTML templates, but for what I know of them,
I'd probably use TextMate

Which editor do you use to edit Ruby source?

TextMate

If Ruby had optional significant whitespace as a core language feature
(maybe
like http://gist.github.com/117694)
, would you use it:

Never, that jus looks awful to me, and very hard to read. Also, it doesn't
let you use some extra indentation.

If your favorite template language is Haml, would you prefer Erector if Ruby
had significant whitespace?
(yes/no/NA)

No, I prefer Erector, as it is, mainly because I love to write pure Ruby

If you actually dislike Haml, is it because of the significant whitespace?
(yes/no/NA)

No, I think it's a good feature in a template for XML-like languages. But
not for a programming language(because it is far more complex syntax than
just XML nodes, ins't it?)

Have you done any significant development in Python?
(yes/no)

Not really, I did a little at a time, and found more easier to write a "end"
and then be able to read it fast than not writing it and be dead if the
indentation got wong.

For example:

def meth(*args)
if args.length && ...
do_something
end
end

def another_meth
end

def third_meth
end

or ?

def meth(*args)
if args.length && ...
do_something

def another_meth

def third_meth


Yes, you get rid of this "useless" end's, but also the readability I think
because you never see the end of a context, you have to deduce it from
lesser indentation, what is not easy when you come to 5 levels...

Just try to "translate" a stdlib of Ruby, and you'll see your pain to read
it after ;)
 
B

Brian Candler

Brian said:
OTOH it doesn't matter to me in HTML, since it's all just content and
nested divs.

Also: with HTML, a missing or badly-overlapping tag will usually go
unnoticed, and may have unpredictable effects in the browser(s). It may
render as intended in one but not in another. With HAML the output is
well-formed always, and at worst my nesting will be wrong (and will be
consistent in all browsers).

With Ruby, if I'm missing an 'end' the code won't run. I'd rather get
the error, so I can correct it, than have the compiler insert end's
silently.
 
R

Roger Pack

What is your favorite Ruby template language for generating HTML?

rhtml

Which editor do you use to edit HTML templates?
e

Which editor do you use to edit Ruby source?
e


If Ruby had optional significant whitespace as a core language feature
(maybe
like http://gist.github.com/117694), would you use it:
- Never?
- Sometimes?
- All the time?
- Don't care?
- Only with different syntax (lazibi, colon, something else?)


Probably all the time, a different syntax might be useful...
Have you done any significant development in Python?
(yes/no)

a bit.
 
D

David Masover

Never in a million years. If I wanted that, I'd be using python.

This is interesting, and came up a lot in the previous discussion -- mostly in
the form of, "If you like significant indentation so much, why don't you just
use Python?"

I do want that, but I don't want Python. Just about everything else that makes
Ruby different than Python makes me want to use Ruby. There are only two
things I would want from Python:

- Execution speed
- Significant indentation.

If I can't have those in Ruby, fine, there are still many reasons I'll use
Ruby instead. And people are working on execution speed.
NA, since I wouldn't be using ruby.

I think that's a no.

And again, _optional_ significant whitespace. Would you stop using Ruby if it
became an option?
I agree it does seem paradoxical that one can like indentation for HTML
but dislike it for programming. For me the following are important:

- HTML has the need for balancing end tags, and the annoying </...>
syntax. With Ruby it's just three characters, 'end'

Same with Erector, though. This is actually one of the few reasons I prefer
Haml to Erector, and there are many things I want from Erector.
 
S

Seebs

And again, _optional_ significant whitespace. Would you stop using Ruby if it
became an option?

I don't think it makes sense to describe it as optional.

If it's there, then the parser has to handle it for any modules which use it.
Which means I have to deal with at least some incoming code using it, and
that means I can no longer trust blocks to have end markers.

You can talk about optional parentheses, because both in the pair are
optional and we know how to detect the argument list. With significant
whitespace, though... It seems like you'd have to know whether or not it
was in use in advance.

But basically, I find significant whitespace a sufficiently high barrier
to reading and maintaining code that, if a noticeable chunk of Ruby code
were written that way, I would probably lose a lot of interest. I frequently
have to read and deal with other peoples' code to get things done, and if
that code were illegible to me, that would be a big downside.

I have yet to comprehend any circumstance in which whitespace significance
does anything but increase the number of undetectable and uncorrectable
failure modes. I'm pretty happy with 1.9 warning about mismatched
indentation, because that DOES actually catch errors. But it only catches
errors because it has an absolutely definite cue (the end token) to compare
with.

-s
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

If Ruby had optional significant whitespace as a core language feature
(maybe
like http://gist.github.com/117694), would you use it:
- Never?
- Sometimes?
- All the time?
- Don't care?
- Only with different syntax (lazibi, colon, something else?)

I would support Haskell-style optional indentation in Ruby, although I can't
say how often I'd use it myself.
 
J

James Britt

David said:
What is your favorite Ruby template language for generating HTML?

Erb or Ezamar, depending on what I'm doing.
Which editor do you use to edit HTML templates?
Vim


Which editor do you use to edit Ruby source?
Vim


If Ruby had optional significant whitespace as a core language feature (maybe
like http://gist.github.com/117694), would you use it:

Maybe. I prefer, for example, the more tolerant offside whitespace rules
of Haskell to the brittle horror of Haml. But Ruby's not Haskell. Each
encourages you to think about programs differently.
If you actually dislike Haml, is it because of the significant whitespace?

Probably; it's a poor syntax because it favors a rigid DOM-centric view
over a fluid document view. (I see programs as documents, e.g. essays,
so whitespace freedom matters. Same for Web pages.)
Have you done any significant development in Python?
(yes/no)

No. Tried it out, and have had to adjust some Python code here and
there for one or another project, but nothing major.

My(__self__) didn't care for it.
That's all.

I welcome opinions, but what I'm after here are either specific, countable
statistics, or a criticism of the questions being asked. I think there will be
a lot more to discuss once we have some numbers.

Ruby already has significant whitespace considerations: '\n' in place of
';', for example. A better term might be "significant indentation".

More clarity on possible forms of significant indentation would be
helpful, too.
Also: Should I cross-post this to the Rails group?

No.

--
James Britt

www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.neurogami.com - Smart application development
 
D

David Masover

I don't think it makes sense to describe it as optional.

Why not?
If it's there, then the parser has to handle it for any modules which use
it. Which means I have to deal with at least some incoming code using it,
and that means I can no longer trust blocks to have end markers.

So, by this logic, use (or lack) of parentheses are optional, as are curly
brackets around hash literals (if they're immediately passed as the last
argument to a method)...
You can talk about optional parentheses, because both in the pair are
optional and we know how to detect the argument list. With significant
whitespace, though... It seems like you'd have to know whether or not it
was in use in advance.

That depends what the syntax looks like. One thing that was proposed was using
a colon:

def some_value:
@some_value

In the last discussion, Matz wasn't opposed to the idea, but he said the
colon, specifically, wouldn't work.
But basically, I find significant whitespace a sufficiently high barrier
to reading and maintaining code that, if a noticeable chunk of Ruby code
were written that way, I would probably lose a lot of interest. I
frequently have to read and deal with other peoples' code to get things
done, and if that code were illegible to me, that would be a big downside.

Do you really not find ways people can write unreadable code in Ruby as it is?
If the problem is unreadable code, the solution is coding standards and
comments.

I don't feel it should be the job of the language to enforce coding standards,
and that is one of the reasons I use Ruby in the first place.

But this is more than I wanted to say, yet.

Ultimately, it's a matter of taste, which is why I'm more interested in how
many people want such a feature than how many people think it should exist.
The biggest pain point for me is HTML generation, so if no one else cares,
I'll just go use Haml.
 
S

Seebs

So, by this logic, use (or lack) of parentheses are optional, as are curly
brackets around hash literals (if they're immediately passed as the last
argument to a method)...

The grammar for parentheses in Ruby is not-optional, but it happens to
allow either form.

Hmm. Here's the thing. You can't do it unless you have some special
token that indicates the start of a block which is whitespace-delimited.
Otherwise, consider:
if true
indented
things
more things
end

Did that block end at "more things" or at "end"?

For it to not be ambiguous, you have to know in advance which one you're
looking for.
Do you really not find ways people can write unreadable code in Ruby as it is?
Oh, sure. But the language is at least theoretically subject to indentation
fixers now. It wouldn't be with this change.
I don't feel it should be the job of the language to enforce coding standards,
and that is one of the reasons I use Ruby in the first place.

I suppose if we're talking about a special thing which introduces blocks,
part of my objection goes away -- it's no longer impossible.

I still can't comprehend wanting that feature -- it's always struck me
as introducing a lot more prospective undiganosible errors than it
could ever remove.

(Disclaimer: I get a lot of mail that's been corrupted by a messaging
server which strips or squashes leading whitespace.)

-s
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top