Pythonic indentation (or: beating a dead horse)

J

Juan Zanos

However, Ruby is about 10 years old now, Python and its insertion is
even older.
If it would be so superior, didn't you think it would have been
widely accepted in the mean time?
And would have been spread over to other scripting languages already?

You might. And you'd be right. Python is widely accepted. Python,
by every indication I'm aware of, is more popular than Ruby. TIOBE
lists Python is slightly more than twice as popular as Ruby (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
). And arguably, excluding any discussion of indentation, Ruby is a
better language. I'm told that at Google they won't even let you
code in Ruby. They only allow a limited number of popular languages,
which includes Python but not Ruby.
 
R

Reid Thompson

Caleb Clausen wrote:
If you'd wanted to indent less than the surrounding code,
then I'd be in trouble. This won't work:

def foo big,
list,
of,
args

some.stuff
some.stuff
some.stuff


something.more.important!
look.at.me!


more.stuff = boring
This would kill me. I utilize temporary code all the time starting in column 0
so that it will be easy to find and pull back out
 
R

Reid Thompson

J said:
Have you noticed that your post is broken into paragraphs, and those
paragraphs are delimited solely by whitespace, and this does not
impair readability?

Have you noticed that this post contains quotes from you, and the
quotes from you contain quotes from me, and these quotes are delimited
from each other solely by indentation, and this does not impair
readability?

Not so. I have varying levels of '>' characters. Having only whitespace in a
back and forth message chain does impair readability as far as I'm concerned.
I ceased long ago using email clients that don't utilize some form of leading
indicator.
 
R

Reid Thompson

If it would be strictly optional it would be fine.
Should be need to be explicitely allowed for not breaking existent code.
Maybe as gem possible.

There's no way it could be *strictly* optional. Unless you provide some way for
persons that want code block ends to automatically convert code without ends to
code with ends.
 
J

Joshua Ballanco

I feel that I did address this point adequately already, so it's
annoying to see both you and Joshua Ballanco bring it up again,
without even acknowledging that I had done so. Perhaps you don't agree
with my points, but as you haven't tried to rebut them, I think it
more likely that you did not read what I had to say at all.

I did not intend to offend by not explicitly calling you out. I did
read that you had worked around this issue by allowing "end"s to be
optional, and I had assumed that most others following this (now
admittedly very long) thread would have as well. Again, I did not
imply that tackling this issue was impossible (despite my poor choice
of example script name). Indeed, I think I even showed how it would
still be possible to do this even without "end".

I fear I did not make my point clearly enough: I prefer do...end to
significant-whitespace. I think this is a commonly held preference,
but by no means globally held. However, mixing and matching seems, to
me, like a BAD idea. Why?

Well, if you're not going to enforce proper indenting when using
do...end, what happens when someone takes working, but poorly
formated, code from a do...end block and copy-pastes it into a block
using indentation instead? You now have code that works in one place
but not in the other. That is, with optional do...end/significant-
whitespace, code that works in one part of a source file might NOT
work in a different part, and the reason for this will be non-obvious.

How about this compromise: Fork Ruby, enforce significant-whitespace,
and instead of writing a preprocessor that converts significant-
whitespace into do...end form, write it to go the other way 'round.
All (or most) of the gems/libraries out there would still be
available, but now you could have a countable number of "Swuby" users
to show the superiority of significant-whitespace.

- Josh
 
G

Gregory Brown

How about this compromise: Fork Ruby, enforce significant-whitespace, and
instead of writing a preprocessor that converts significant-whitespace into
do...end form, write it to go the other way 'round. All (or most) of the
gems/libraries out there would still be available, but now you could have a
countable number of "Swuby" users to show the superiority of
significant-whitespace.

This actually is about the most sensible thing I've seen in this
thread, hands down. Whether or not it showed superiority, it could
show utility.

-greg
 
M

Michael Bruschkewitz

Reid Thompson said:
There's no way it could be *strictly* optional.

I dont really understand this sentence (too much indirection - I'm german
and I'm tired...) Did you mean "It must be strictly optional" ?
Unless you provide some way for
persons that want code block ends to automatically convert code without
ends to
code with ends.

Maybe any code in any language should be stored in some generic form meta
language (we would have enough space to store it now - car crysis left
enough oil to create magnetic tapes) and the _Editor_ provides the view
which best fits to the current developer. (Example: translate keyword to
japanese signs, direction of writing a.s.o.)
Editor could also apply current coding rules. The would increase code safety
and security, and efficiency. It would even allow GUI's for creating code
from/by Flowcharts.

I'm really serious.
This would be really a revolutionary improvement. (Removing most reasons for
current holy wars and create a huge field for new, interesting ones.)
But these backbone language would not be Ruby.

Also, IMHO, PyI wouldt break principle of least surprise.

At breakfast I had the idea it would be possible to implement/apply it to
current file it by simply using
"require 'tool4endH8ers.rb'" or
"require 'languageConverter_pyi.rb'" or
"require 'languageConverter_BASIC.rb'" or
"require 'languageConverter_f77.rb'" or...
"require 'applySomeOtherWeirdOptions.rb'" or...
at the beginning of each file or at the beginning of main file.
I'm sure some Kernel.magic would make this possible.

Why not think about providing a mechanism which provides this possibility?

Regards,
Michael B.
 
M

Michael Bruschkewitz

Gregory Brown said:
The same way you block users with intent to offend (or not) who do not
use vulgar language, with a kill-file in your mail client. Another
way to avoid such discourse is to not act like a troll with no respect
for the other members of this list.

-greg

Offender may have some problems staying kind and friendly.
People feeling offended have problems beeing tolerant.
(They should just skip the post when tolerance limit is reached.)
It is the same sort of social disability.

Some offendings may come from in-familiarity to english language or cultural
differences.
Never offer left hand to muslims, for example. I had absolutely no idea
about this problem until I read/heard about real reason.

In this NG we should concentrae on language issues.

Best Regards,
Michael B.
 
J

Juan Zanos

Offender may have some problems staying kind and friendly.
People feeling offended have problems beeing tolerant.
(They should just skip the post when tolerance limit is reached.)
It is the same sort of social disability.

Some offendings may come from in-familiarity to english language or
cultural differences.
Never offer left hand to muslims, for example. I had absolutely no
idea about this problem until I read/heard about real reason.

In this NG we should concentrae on language issues.

It's impossible to never offend. You can't please everybody all the
time as they say. But in this case
there was no language misunderstanding. The poster's intent was
specifically to be vulgar and offensive. It's perfectly reasonable to
reject abusive behavior.
 
G

Gregory Brown

It's impossible to never offend. =A0You can't please everybody all the ti= me as
they say. =A0But in this case
there was no language misunderstanding. =A0 The poster's intent was
specifically to be vulgar and offensive. =A0It's perfectly reasonable to
reject abusive behavior.

In all seriousness, I've found your behavior on this list abusive, and
I was venting my frustration. I should have done that in a private
mail, but please do not push this issue and make it sound like I'm the
source of great pain and suffering here.

People only need to search the archives to see what my contributions
to this list have been like.

-greg
 
M

Michael Bruschkewitz

It's impossible to never offend. You can't please everybody all the
time as they say. But in this case
there was no language misunderstanding. The poster's intent was
specifically to be vulgar and offensive. It's perfectly reasonable to
reject abusive behavior.

Maybe it was just a very special try of being funny?

If somebody is really vulgar and offensive, he dis-qualifies himself.
IMHO, more than a *shrug* and ignore offensive wording would not be
appropriate.
There is no need for guards of morale in NG if everybody (who is possible to
do that) tries to remain calm.

I, personally, prefer people calling me asshole to friendly stupids.

Let's stop wasting our resources.
 
R

Reid Thompson

I dont really understand this sentence (too much indirection - I'm german
and I'm tired...) Did you mean "It must be strictly optional" ?
What I mean is..
if endless ruby code is allowed, it cannot be strictly optional. If a
core class or any other class/project that you utilize is coded without
ends, then you get endless ruby whether you want it or not.
 
C

Caleb Clausen

Caleb, have you thought about toying around with forking Ruby and
invoking your pre-processor automatically in some way? I think
that'd turn this conversation into something much more productive.

It wouldn't be very hard, but that's more effort than I want to put
into it right now.
Even if it's not a realistic implementation at first, it could lead to
productive discussion on how it could be integrated, and what
syntactic changes it would need to make Matz happy.

I made it to prove a point, and I feel what I've done now is a
sufficient proof that it can be done, without buggy regex hackery, or
particular difficulty (given you have an already working lexer) and
the result can have very clean syntax.
 
G

Gregory Brown

I made it to prove a point, and I feel =A0what I've done now is a
sufficient proof that it can be done, without buggy regex hackery, or
particular difficulty (given you have an already working lexer) and
the result can have very clean syntax.

Yeah, that was very surprising. Good work on that man, hopefully
it'll be put to good use, but anyway, it's nice to see the idea tried
out.

-greg
 
M

Marc Heiler

Maybe it was just a very special try of being funny?

Whoever wrote it can clear this up easily by stating what his intention
was.

Personally, my experience was that sarcasm or irony often does not bode
well in written text. Additionally, often people assume that something
is insulting or otherwise harmful against them - written text is often
limited in expressing human *intentions*. Or, some people have a hard
time expressing their thoughts.

But anyway, let's jump to the proposal again (and we can see that this
generated quite a stir... huge huge huge here hehe.)

I dont want to write too much, so I try to be short and concise:

- Personally, i think it *would* be nice to omit "end" and have my code
still work. I do indent my code already with two spaces all the time for
every meaningful code block anyway. Those "end's" aren't really helpful
for my eyes.

- I do however not have a serious problem with that. It would be nice,
but it is nothing where I would say "ruby sucks" because I cant omit
ends. To me, it is not really important.

- As far as language design is concerned, I personally think it is not
elegant if a parser bothers too much about meaningful indent. Instead, I
think a parser should try to capture the INTENT of the programmer, and
it is stupid if a parser stops working because the INDENT was wrong. It
just strikes me as inelegant - and keep in mind that I said, I wouldn't
mind to omit end at all.
I found it silly to not be able to just paste code into the interactive
python shell, and have it work. It complained about whitespace crap, and
I found this insulting. I think the best way would be for a parser who
could allow for both, with "end" being the default, but a switch which
could allow for a shorter ruby-like syntax where one can omit "end".

- I think python has one solid argument going for it (and please also
keep in mind that I hate other python choices, especially the __foo__():
part. That includes the ':' in there as well) - whitespace and
homogeneous structure would be something _I_ would appreciate. I love
ruby's flexibility, but I would also love to have something
super-concise AND homogeneous. And more readable, IMHO, too.

- As written above, I have one problem with the python whitespace. And
this is the ':' part. I hate that.

'if foo:'

I do NOT want to get rid of "end" in ruby, if that means introducing
something like ':'. The ':' is not beautiful at all, and thus it would
not be a real improvement for me, if I have to clutter my code with ':'.

- I do not think that you applied the DRY statement correctly, because
DRY applies for code logic primarily, not for satisfying a parser. And
the "end" is there because of the parser.

Programmers shouldn't be using freakin' tabs anyway,
and if they are, they _definitely_ shouldn't be mixing them with spaces.

Personally I used to like tabs, and reasoned that people could set their
tabs width to whatever they like. But then I realized that i do comment
my own code a lot, and suddenly I was mixing tabs with spaces.

I stopped at that very day, and used 2 spaces (2, because I usually like
to have 80 chars per line, and not more. I am that old, really. I like
80 chars per line, even though i sometimes use more than that - i think
it is a good general rule of thumb to cut down below 80 chars / line,
and with 4 spaces i just hit that threshold sooner)


Anyway, I think this is all mostly just happy discussing here. Ruby is
the way it is, and to change something as fundamental as indent is way
too difficult and probably has no huge gain whatsoever. Didn't Guido
once say that, if he could switch one thing in python, he would no
longer use significant whitespace?
 
M

Michael Bruschkewitz

Reid Thompson said:
What I mean is..
if endless ruby code is allowed, it cannot be strictly optional. If a
core class or any other class/project that you utilize is coded without
ends, then you get endless ruby whether you want it or not.

For this reason, wouldn't it be possible to add an "option"-parameter to
"require"?
 
E

Eleanor McHugh

I never said it was. In fact, in my response to you I didn't
mention significant indentation at all. I disagreed with the
current anti-conciseness arguments. I suggested that if you want
to argue against a language feature then you need stronger arguments
than terse is hard to read. Possibly the problem is the term
terse is being used incorrectly. It doesn't mean hard to read.
Terse may mean "smoothly elegant, neat, clean, easy to understand,
or even brusque. But it doesn't mean hard to read.

We may well be separated by a common language. It's unusual here in
the UK for anyone to use the word 'terse' without meaning brusque with
a tendency to rudeness, and when applied to code it's common currency
for "reads like obfuscated C".
I'm perfectly happy if you have good arguments against any
particular language feature including significant indentation.
I'll be happy to agree with your criticisms If I can find some
validity in them. I don't own stock in any language features.

I am a bit intrigued by these indentation ideas though. In both
human and computer languages we tend to shorten things that we use
often -- even if it makes them irregular. The 'end' word is one
of the most common things in Ruby. Possibly the most common line in
Ruby contains nothing but 'end'. It's perfectly reasonable to think
about the possibility of shortening it.


True. But removing it altogether isn't the same as abbreviating it
(even txtspk leaves *some* of the characters in words to convey
meaning).


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
J

James Britt

Gregory said:
In all seriousness, I've found your behavior on this list abusive, and
I was venting my frustration. I should have done that in a private
mail, but please do not push this issue and make it sound like I'm the
source of great pain and suffering here.

People only need to search the archives to see what my contributions
to this list have been like.

Exactly true.

I'm offended by anyone trying to make Greg out to be some sort of
willfully and routinely vulgar troll.

His contributions to Ruby have been amazing, and I'm more than willing
to cut him whatever slack he needs.

Maybe some reflection on what might provoke someone such as Greg to
respond like that is more in order.


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

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top