Indentation vs. "end"s

R

Rubyist

Hi,

I *REALLY* love Ruby very much. But I always find those "end"s somewhat
ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
that Ruby use indentation (as Python does) instead of "end"s.

Today, I have seen a post in:

http://www.artima.com/weblogs/viewpost.jsp?thread=146091


As far as I know, Bruce Eckel is a competent programmer and when I saw
that he was agree with me, I surprised.

What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?
 
L

Luke Duncalfe

Rubyist said:
Hi,

I *REALLY* love Ruby very much. But I always find those "end"s somewhat
ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
that Ruby use indentation (as Python does) instead of "end"s.

Today, I have seen a post in:

http://www.artima.com/weblogs/viewpost.jsp?thread=146091


As far as I know, Bruce Eckel is a competent programmer and when I saw
that he was agree with me, I surprised.

What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?


I've got to declare that I also like the idea of dropping the ends a la
Python, although if the effect of that is that your whitespace becomes
strict I'm not sure which way is better. I have looked at some of my and
other people's Ruby code and often been tempted to select those last 5
'ends' and hit the delete button. : )

Luke
 
D

doug00

Yes I really like the end statements, and they make it easier for
beginners. It's possible to support both indenting and end statements
(i.e. support one mode or the other), and you don't need python's
redundant and unnecessary colons. I implemented this myself in a
parser. I don't think it is appropriate for ruby, however.

What would be even better would be to allow optional labels after end
statements, such as "end class", "end def", so the parser can catch
more errors.
I've implemented this as well in a separate project.
 
P

Phil Tomson

I like having something to search for in my editor. Explicit
block-ending tokens also help when I am skimming code to review its
structure.

And having 'end' sure makes things like ERB easier (possible) to implement.


Phil
 
R

Rubyist

I have looked at some of my and other people's Ruby code and
Thank God! I am not alone on the earth! ;-D
Man, you've made me so laughed! Hahaha!
 
R

Rubyist

What would be even better would be to allow optional labels after end
That sound like a good idea. But what about "if", "when", "for",
"until" etc?
Hmm...
"endif", "end when", "end for", "end until", "end class", "enddef",...
Umh! A never "ended" nightmare.
 
N

ngw

-Rubyist said:
What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?

You're asking for trouble when using something like eruby.

ngw
 
D

Dirk Meijer

------=_Part_4848_1679628.1138830527534
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

i like the "end"s, it reminds me of the old days when i programmed my Texas
Instruments calculator and always forgot an "end" somewhere :p

2006/2/1 said:
And having 'end' sure makes things like ERB easier (possible) to
implement.


Phil

------=_Part_4848_1679628.1138830527534--
 
E

Eric Hodel

I've got to declare that I also like the idea of dropping the ends
a la
Python, although if the effect of that is that your whitespace becomes
strict I'm not sure which way is better. I have looked at some of
my and
other people's Ruby code and often been tempted to select those last 5
'ends' and hit the delete button. : )

I typically find I'm doing something wrong if I have five ends in a
row. Too much complexity in one method. Three is usually my max,
but I don't make a rule of it, it just happens.
 
R

Robert Klemme

2006/2/1 said:
Hi,

I *REALLY* love Ruby very much. But I always find those "end"s somewhat
ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
that Ruby use indentation (as Python does) instead of "end"s.
What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?

I don't even think about them. I just use the language as it is.

robert
 
A

Austin Ziegler

I *REALLY* love Ruby very much. But I always find those "end"s somewhat
ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
that Ruby use indentation (as Python does) instead of "end"s.

Today, I have seen a post in:
http://www.artima.com/weblogs/viewpost.jsp?thread=3D146091

As far as I know, Bruce Eckel is a competent programmer and when I saw
that he was agree with me, I surprised.

What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?

I hope that the mistake that Python makes isn't repeated in Ruby 2.0.

I prefer explicit -- and more flexible -- than implicit and
inflexible. In other words, I really *do* like the ends.

-austin
 
A

Austin Ziegler

That sound like a good idea. But what about "if", "when", "for",
"until" etc?
Hmm...
"endif", "end when", "end for", "end until", "end class", "enddef",...
Umh! A never "ended" nightmare.

I'm not particularly fond of IF ... ENDIF constructs, but one can simulate =
this:

def foo
...
end # def foo

I don't do it, though. Vim does a damn fine job of folding things for me.

-austin
 
D

David Vallner

What would be even better would be to allow optional labels after end
statements, such as "end class", "end def", so the parser can catch
more errors.
I've implemented this as well in a separate project.

Holy mother of god in the heavens, for the love of all that's good and sacred,
please NO! I've had more than enough XML and VHDL already, thankyouverymuch.
Next thing you see we're coding in palindromes to doublecheck we know what
order we wrote the characters in...

I want to see a single half-serious programmer that actually makes errors
because he can't remember what scope he's in. That's what the indentation
conventions are there anyway. If you keep your code well-structured, It's
impossible to have that cause a show-stopping bug that can survive five
minutes in the codebase.

That said, I prefer indentation as a convention, not as syntax. I made certain
sporadic forays into Python; but I like how Ruby tries to resemble natural
language with the likes of statement modifiers, and do/begin and end for code
blocks. It feels more natural to me to type "end" to end a code block, and I
usually associate the backspace key probably the most commonly used in
editors to unindent code manually with correcting typos - ergo not a natural
component in the flow of typing.

Pretty much my $.02

David Vallner
If I had two cents for everytime I say "Just my two cents"...
 
G

gwtmp01

I typically find I'm doing something wrong if I have five ends in a
row. Too much complexity in one method. Three is usually my max,
but I don't make a rule of it, it just happens.

+1


Gary Wright
 
G

gbanfalvi

I'm pretty much a newbie programmer so my opinion shouldn't count much
but before I chose Ruby as the definite language I tried writing in as
many other languages as I could, including Python.

I understand the importance of indentation, but forcing it on me was
really painful. I honestly wanted to stab someone every time I got an
error (ruby give me an error too when I missed an end, but it's somehow
different). There is something incredibly soothing about writing
freeform and freestyle code in Ruby which I don't get in Python.

What I'm afraid of now is going to college next year and having to deal
with "stricter" languages.

Good Luck!
Gabriel

PS: Yes, I know writing code cowboy style is bad, but hey, I'm a
newbie. ;)
 
S

Serdar Kýlýç

Honestly, I prefer ENDs to indentation, I prefer curly braces to ENDs.
But how about something like this:
def foo
@var
}
 
J

James Britt

...
I understand the importance of indentation, but forcing it on me was
really painful. I honestly wanted to stab someone every time I got an
error (ruby give me an error too when I missed an end, but it's somehow
different). There is something incredibly soothing about writing
freeform and freestyle code in Ruby which I don't get in Python.

Same here. My editor fills in the 'end' stuff for me, so there is no
extra typing. But I have the freedom to adjust the layout to highlight
sections of code to better express intent.
What I'm afraid of now is going to college next year and having to deal
with "stricter" languages.

Well, that sinks it: Skip college. Code Ruby.

Actually, experience with a variety of languages is usually a Good
Thing, at least to give some perspective.

--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 
H

Hal Fulton

Yes I really like the end statements, and they make it easier for
beginners. It's possible to support both indenting and end statements
(i.e. support one mode or the other), and you don't need python's
redundant and unnecessary colons. I implemented this myself in a
parser. I don't think it is appropriate for ruby, however.

What would be even better would be to allow optional labels after end
statements, such as "end class", "end def", so the parser can catch
more errors.
I've implemented this as well in a separate project.

Not a bad idea in itself. In fact, I think that really old Ruby
versions (prior to my learning it with 1.4) did something like
that. When modifiers were introduced (x if y, x while y, etc.)
parsing became difficult and they were dropped. I think that's
the case.


Hal
 
D

Dirk Meijer

------=_Part_9341_32239222.1138861410742
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

2006/2/2 said:
I loved my TI-82, and I remember how excited I was over my 85. Now that
I'm a grown-up, of course, I have a Voyage 200. :)
i used the ti-83+, and still do (as i'm still in high school) i just don't
program it as much as i used to :p
but anyway, one thing i would like better than the current "end"s, is
wrapping everything in do/end like this:

while condition? do
#action
end

or maybe even:

if condition?
then do
#action
else do
#action
end

greetings, Dirk.

------=_Part_9341_32239222.1138861410742--
 
J

Jim Freeze

--Apple-Mail-1--505555067
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

Thank God! I am not alone on the earth! ;-D
Man, you've made me so laughed! Hahaha!

I think we can learn a lot from programming languages and Python.
First off, we should be writing in a fixed space font so we
can take visual cues from spacing more easily.
Next, why do we need periods at the end of a sentence
when we know that two spaces after a word mean
that the previous sentence just ended Doesn't
that make sense And do we really need caps at
the beginning of a sentence we know all sentences
are capitalized and we have just defined that
two spaces before a word means that it is at the
beginning of a sentence next we should look at
spelling double consonants don't realy add to
the meaning so begining now we spel words by
droping repeated consonants just look at al
these great benefits we can learn from python
self.we self.just self.need self.to self.learn
self.to self.ignore self.certain self.aspects
self.that self.may self.cary self.over

--
Jim Freeze




--Apple-Mail-1--505555067--
 

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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top