Re: Why not adopt "Python Style" indentation for Ruby?



Chad Perrin wrote:
On Sun, May 20, 2007 at 12:05:06AM +0900, Brendan wrote:
On May 18, 4:23 am, Chris Dew <cms...@xxxxxxxxxxxxxx> wrote:
...
with no reduction in meaning, yet 25% fewer lines of code.

What are the reasons why this isn't used/implemented/liked? It would
be a small change to the interpreter. Enabling meaningful indentation
would only make 'end' optional, not invalid; backwards compatibility
wouldn't be a problem.

(I use both Ruby and Python. I think indentation is one of the few
*language* features where Python leads Ruby.)
I personally prefer that 'end' be in place, so that all ruby code is
readable. I personally believe there may be something wrong with a
syntax which sacrifices explicit readability (for everyone, not just
python programmers) for increased typing speed and the illusory gain
of 'fewer LOC'. This was one of the major reasons which convinced me
to use ruby instead of python.

I, personally, don't have an argument on principle like that for my own
preferences in this matter. I just like the fact that an "end" makes it
look more complete to me. Reading Python code always makes me feel like
my eyes are just going to trail off the right-hand edge of the page
because the "shape" of the code never brings me back to the leftmost
edge, the way code "should".

When I look at Python code, and ponder the way it does things so
differently from Ruby regarding delimiters and indentation (the same
thing in Python), it seems to me that Python was created for people who
write code in a particular mindset, and it's not a mindset I share when
I'm writing code. I guess maybe some people, when writing code, think
in footnote hierarchies, while others (like me) think in nested scopes.

That's just an off-the-cuff hypothesis.

I've been watching this debate go by for some time, and I'm not sure this sort of thing can ever be solved, but here are my personal opinions:

1. When you come right down to it, there are only a few basic syntax styles that have survived the test of time. *Most* languages, including C, Ruby, Pascal and Perl, use some variant of the Algol 60 syntax. The other "survivors" are the Lisp/Scheme variant of prefix notation, Forth's postfix notation, and the regular expression syntax. I suppose assembly language syntax has also survived, and FORTRAN and COBOL, but I don't think anyone would design a new language with those.

2. I think Python's "variant" of Algol 60 notation is less than satisfactory, but I also have problems with the liberality present in the syntax of Perl and Ruby. I don't like to make the reader or parser work any harder than necessary just for the convenience of the coder. So I like explicit delimiters like curly braces, parentheses, mandatory semicolons at the end of statements, begin/end pairs, etc. for the Algol 60 languages. Lisp/Scheme and Forth were deliberately designed to make the parser's job trivial, and I like them too. :)

3. I've pretty much given up on the dream that I'll be able to program in one language only, although some languages are close enough. At the moment, I can get just about everything done in either Perl or R, with the other languages simply being fun to learn and use but not essential. I could probably eliminate Perl if there were more R programmers, but there aren't and won't be, because R is designed for scientists and mathematicians, not business people.



.



Relevant Pages

  • Re: Ruby vs. PHP
    ... done is checked out which versions of Perl, Python, YARV, Ruby, jRuby ... dynamic language to the seconds for the benchmark with gcc. ... YARV, Python, Perl and PHP have fairly close medians and the boxes are ...
    (comp.lang.ruby)
  • Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1
    ... having come here from many years with another scripting language. ... Ruby Maniac wrote: ... Ruby syntax seems to favor the notion that fewer characters is better ... Python runtimes are not affected by the number of characters one uses ...
    (comp.lang.ruby)
  • Re: Why dont people like lisp?
    ... > Everybody CAN contribute to Python! ... If it were only about making small alterations to the syntax, ... full-fledged language constructs. ... Lisp-style Macros make these things a breeze. ...
    (comp.lang.python)
  • Re: Why dont people like lisp?
    ... > Everybody CAN contribute to Python! ... If it were only about making small alterations to the syntax, ... full-fledged language constructs. ... Lisp-style Macros make these things a breeze. ...
    (comp.lang.lisp)
  • Re: Forth and Unix -- history
    ... can extend the compiler and the syntax if you want). ... I wouldn't call lack of built-in assembler a weakness, when there is good FFI, ... When you redefine syntax, you develop another language, and there're good ... in Python you can manipulate AST. ...
    (comp.lang.forth)