Ruby's "More than one way to do things."

There is one point made about Python vs. Ruby on this site:
http://c2.com/cgi/wiki?PythonVsRuby that interests me:

It is this:
Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Do you agree that Ruby emphasizes having more than one way to do it more
than Python does? Do you believe this is a good thing for Ruby? Why?

I personally like to have structure in my life and feel okay with having
only one way, but then - I've never really programmed anything in Python
before so I can't really make a good comparison.

Thank you for any thoughts.

Jason

···

--
Posted via http://www.ruby-forum.com/.

Hi,

There is one point made about Python vs. Ruby on this site:
http://c2.com/cgi/wiki?PythonVsRuby that interests me:

It is this:
Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Do you agree that Ruby emphasizes having more than one way to do it more
than Python does? Do you believe this is a good thing for Ruby? Why?

"There is more than one way to do it" is the slogan we borrowed from
the Perl community. I cannot speak for the Perl community, but for
us, the slogan expresses the importance of diversity. But we do not
love diversity for no reason. We do not want confusion, for the sake
of diversity. So to rephrase: "There should be more than one way to
do it, if having many way is rational, depending on often untold
context".

              matz.

···

In message "Re: Ruby's "More than one way to do things."" on Thu, 25 Nov 2010 06:16:16 +0900, Jason Lillywhite <jason.lillywhite@gmail.com> writes:

There are more than one way to do things because different programmers
come from different languages may prefer different style. In python
everything can be readable from one python programmer to the next
because of how it is.

Ruby expects people to be migrating from C, C++, Java, Python, Perl,
Lisp, sh, etc.

Each type of programmer may have a different perspective on the "one
true way" to express themselves.

Though a couple of years old please refer to this link:
http://www.artima.com/intv/ruby3.html

···

On Wed, Nov 24, 2010 at 3:16 PM, Jason Lillywhite <jason.lillywhite@gmail.com> wrote:

There is one point made about Python vs. Ruby on this site:
http://c2.com/cgi/wiki?PythonVsRuby that interests me:

It is this:
Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Do you agree that Ruby emphasizes having more than one way to do it more
than Python does? Do you believe this is a good thing for Ruby? Why?

I personally like to have structure in my life and feel okay with having
only one way, but then - I've never really programmed anything in Python
before so I can't really make a good comparison.

Thank you for any thoughts.

Jason

--
Posted via http://www.ruby-forum.com/\.

If I want to walk to my friend's house, why should I have to go in the same manner as you? When you walked to my friend's house it was raining, so you didn't take the newspaper with you, and you didn't dally. Today I am going to my friend's house and it is sunny. I think I will take him the newspaper, and stop periodically under nearby trees for some shade. I might even detour to the ice cream shop.

It's good to know however, that we can both walk to my friend's house.

Sam

···

On 25/11/10 10:16, Jason Lillywhite wrote:

There is one point made about Python vs. Ruby on this site:
http://c2.com/cgi/wiki?PythonVsRuby that interests me:

It is this:
Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Do you agree that Ruby emphasizes having more than one way to do it more
than Python does? Do you believe this is a good thing for Ruby? Why?

I personally like to have structure in my life and feel okay with having
only one way, but then - I've never really programmed anything in Python
before so I can't really make a good comparison.

Thank you for any thoughts.

Jason

Thanks everyone for commenting. I really enjoy using Ruby compared to
Java and the documentation and community is great. That has kept me a
big fan of Ruby.

I'm honored to see that Matz himself has commented on this thread.

I use Ruby for math and scientific purposes so this is the main reason I
started looking at Python in the first place - it is used a lot by
people like me.

···

--
Posted via http://www.ruby-forum.com/.

Ruby is very laid back. Although able to talk passionately at great
length about sophisticated object oriented issues, it is equally relaxed
about spending the entire evening in the company of down-to-earth
procedural programmers.

You ought to enjoy choosing which way you want to do things. We're
pushed about too much these days.

···

--
Posted via http://www.ruby-forum.com/.

I think that that word 'obvious' is rather subjective. I've found
lots of things in programming, and life, which are obvious to others
but not to me.

What we've experienced before shapes what seems obvious.

So if there's more than one way to do something, I might find a
different one (or ones) obvious than someone else. If there's only
one way some folks will have a harder time finding it.

This is somewhat related to Ruby's Principle of Least Surprise. This
also is subjective, and really means at the end least surprising from
Matz's view point. Luckily for me, I tend to see things similarly to
him more often than not.

···

On Wed, Nov 24, 2010 at 4:16 PM, Jason Lillywhite <jason.lillywhite@gmail.com> wrote:

t is this:
Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Programming languages -- at least, good programming languages -- shouldn't try to make programmers into better programmers, or force them to work in a certain way in order to get results. (Imagine a toolbox that told you off for using the wrong screwdriver!)

The two main reasons I really, really love Ruby: (1) Good cognitive fit: the easy way is generally the way my brain works. (2) on the rare occasions when (1) isn't true, I'm usually free to do it my way anyway.

···

--
It's amazing how nice people are to you when they know you're going away.
    -- Michael Arlen

Thank you everyone for taking the time to reply to my question. This has
been a very enlightening experience for me.

···

--
Posted via http://www.ruby-forum.com/.

Also: Even though we are all computer programmers (kind of), we come
from a diversity of fields of expertise, let alone different worlds of
programming languages / paradigms / experiences.
Ruby is imho the language that allows developers who've done Perl, C,
asm, (python), JavaScript, Pascal, whatever before to all work on the
same page, while everyone still gets some aspects of their most
comforting language.

···

On Thu, 2010-11-25 at 06:31 +0900, Yukihiro Matsumoto wrote:

Hi,

In message "Re: Ruby's "More than one way to do things."" > on Thu, 25 Nov 2010 06:16:16 +0900, Jason Lillywhite <jason.lillywhite@gmail.com> writes:

>There is one point made about Python vs. Ruby on this site:
>http://c2.com/cgi/wiki?PythonVsRuby that interests me:
>
>It is this:
>Ruby: "There is more than one way to do it."
>Python: "There should be one - and preferably only one - obvious way to
>do it."
>
>Do you agree that Ruby emphasizes having more than one way to do it more
>than Python does? Do you believe this is a good thing for Ruby? Why?

"There is more than one way to do it" is the slogan we borrowed from
the Perl community. I cannot speak for the Perl community, but for
us, the slogan expresses the importance of diversity. But we do not
love diversity for no reason. We do not want confusion, for the sake
of diversity. So to rephrase: "There should be more than one way to
do it, if having many way is rational, depending on often untold
context".

              matz.

I couldn't agree more. There is no island of simplicity. Ruby is a pragmatic language and wants to be exploited—not shoe-horned.

···

On Nov 24, 2010, at 1:31 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

Hi,

In message "Re: Ruby's "More than one way to do things."" > on Thu, 25 Nov 2010 06:16:16 +0900, Jason Lillywhite <jason.lillywhite@gmail.com> writes:

>There is one point made about Python vs. Ruby on this site:
>http://c2.com/cgi/wiki?PythonVsRuby that interests me:
>
>It is this:
>Ruby: "There is more than one way to do it."
>Python: "There should be one - and preferably only one - obvious way to
>do it."
>
>Do you agree that Ruby emphasizes having more than one way to do it more
>than Python does? Do you believe this is a good thing for Ruby? Why?

"There is more than one way to do it" is the slogan we borrowed from
the Perl community. I cannot speak for the Perl community, but for
us, the slogan expresses the importance of diversity. But we do not
love diversity for no reason. We do not want confusion, for the sake
of diversity. So to rephrase: "There should be more than one way to
do it, if having many way is rational, depending on often untold
context".

                           matz.

In article <E1PLMwJ-0004L3-9J@x61.netlab.jp>,

I cannot speak for the Perl community, but for
us, the slogan expresses the importance of diversity. But we do not
love diversity for no reason. We do not want confusion, for the sake
of diversity.

As someone who still has much more Perl under their belt than Ruby, mark
me down as one of the people who appreciates that. I can't count the
number of times I've come across Perl code that does crazy stuff just
because someone wanted to show off how well they knew deep language
tricks more than they wanted write maintainable code. Combined with the
cruft Perl has accumulated over the years, it's not hard to explain to
people why Ruby makes a better go-to scripting language in most cases.

···

Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

--
iPhone apps that matter: http://appstore.subsume.com/
My personal UDP list: 127.0.0.1, localhost, googlegroups.com, astraweb.com,
    and probably your server, too.

Welcome to the community: you'll love it here! :slight_smile:

Indeed the diversity is one of the strongest assets of the Ruby
community, and hence the Ruby ecosystem too. Both in the way the
language works, the people, the interests, etc... And it's full of
people ready to push the envelope who are always trying to improve the
status quo (so much so that some may find the community suffers a bit
from ADHD, but personally I love it that way! :slight_smile: )

That said as a fellow math/science Ruby programmer, most of the
scientific community seems to have "chosen" Python. Personally I think
that's a pity, maybe due to some misunderstanding on what Ruby is (I
got people surprised when I tell them I program in Ruby: "But I
thought Ruby was just for the web, like PHP"). The Ruby language I
think it's an excellent language for science, but alas the poor usage
by the math/science community has resulted in very few libraries.

A lot of the original hype behind Ruby was due to Rails, so it's
understandable that a lot of libraries are web-oriented. As time
progresses the interest has spread out, first to "neighbouring" topics
and now to more general things. That said science/math seems still a
bit far from where the "action" is, and hence we hardly get much in
terms of fancy, cutting edge libraries.

I don't want to discourage you! As I said I use Ruby too, and there's
no real reason why Ruby could not become a great scientific language.
But I thought it only fair to warn you: the language is great, but the
libraries are a bit lacking. It's a "fixable" problem, but we need
"brave" people to break this chicken and egg situation. (this is all
personal opinion, of course, others may disagree). :slight_smile:

Once again, welcome to the Ruby community! :wink:

Diego

P.S. Make sure to check the NArray gem. It's pretty much a requirement
for anything math related. You may also be interested in Tioga or the
Gnuplot gem if you need to do plotting, and RSRuby if you need to use
R.

···

On Nov 24, 11:35 pm, Jason Lillywhite <jason.lillywh...@gmail.com> wrote:

I use Ruby for math and scientific purposes so this is the main reason I
started looking at Python in the first place - it is used a lot by
people like me.

I believe that's almost 100% wrong. A programming language that doesn't
try to make better programmers ends up enabling poor programming practices,
which ends up producing poor programs. That results in programs and web
sites that crash, which brings on a bad reputation for programmers in
general.

PHP is a great example. It is possible to write good programs in PHP, but
it's also very, very easy to write bad programs in PHP. The result is that
most of the PHP samples you find on the web are absolute crap -- delicate,
unsafe, unmaintainable. The programmers don't realize this, and so the
crap reproduces like a virus.

A toolbox certainly OUGHT to tell me off if I try to unscrew a slotted head
screw with a Philips screwdriver, if that saves me from taking a chunk out
of my hand as I do it.

···

Shadowfirebird <shadowfirebird@gmail.com> wrote:

Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Programming languages -- at least, good programming languages -- shouldn't
try to make programmers into better programmers, or force them to work in
a certain way in order to get results. (Imagine a toolbox that told you
off for using the wrong screwdriver!)

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

This is an interesting blog post and discussion on the topic

http://www.reddit.com/r/programming/comments/ecyef/ruby_is_beautiful_but_im_moving_to_python

martin

···

On Thu, Nov 25, 2010 at 5:05 AM, Jason Lillywhite <jason.lillywhite@gmail.com> wrote:

I use Ruby for math and scientific purposes so this is the main reason I
started looking at Python in the first place - it is used a lot by
people like me.

Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Programming languages -- at least, good programming languages -- shouldn't
try to make programmers into better programmers, or force them to work in
a certain way in order to get results. (Imagine a toolbox that told you
off for using the wrong screwdriver!)

I believe that's almost 100% wrong. A programming language that doesn't
try to make better programmers ends up enabling poor programming practices,
which ends up producing poor programs. That results in programs and web
sites that crash, which brings on a bad reputation for programmers in
general.

I believe you are 100% wrong, There is no way to force people into
writing good code as there is no way forcing people into writing good
novels. You can learn to write decently one or the other by education
and training but neither can be forced, and the less expressive the
language the poorer the result. While the programs are also read by
the computer good code should be readable by humans and freedom in
choosing your expression gives you the option to express things
differently to fit a particular context.

PHP is a great example. It is possible to write good programs in PHP, but
it's also very, very easy to write bad programs in PHP. The result is that
most of the PHP samples you find on the web are absolute crap -- delicate,
unsafe, unmaintainable. The programmers don't realize this, and so the
crap reproduces like a virus.

PHP is a poor example as it is a poor language in general. By its
inconsistency, inflexibility and lack of crucial features it
encourages poor code and code duplication so it is much harder to
write good code in a Personal Homepage Preprocessor than an actual
programming language.

Thanks

MIchal

···

On 29 November 2010 05:40, Tim Roberts <timr@probo.com> wrote:

Shadowfirebird <shadowfirebird@gmail.com> wrote:

After all those years I am unsure how big the impact of a language is.
What I'd consider facts (in no particular order):

1. A programming language can do little to nothing to help you decide
how you lay out functionality across program code artifacts
(functions, procedures, methods, classes). But this (along with
naming of things) has a dramatic impact on readability and
reusability.

2. Good libraries which enforce particular usage patterns can do a
great deal to guide their users to a proper code structure. - But they
cannot prevent creating a mess if one tries to.

3. A key factor for writing good code is the person doing the writing.
People not interested to learn or otherwise improve their work are
unlikely to write better code. The same holds for people who do not
have a chance to improve because they are constantly buried under
loads of work since they lack the time needed for reflection.

4. Removing obstacles to writing good code (compare for example Ruby's
OO with Perl's) certainly helps people writing better code.

My 0.02 EUR.

Kind regards

robert

···

On Mon, Nov 29, 2010 at 5:40 AM, Tim Roberts <timr@probo.com> wrote:

Shadowfirebird <shadowfirebird@gmail.com> wrote:

Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Programming languages -- at least, good programming languages -- shouldn't
try to make programmers into better programmers, or force them to work in
a certain way in order to get results. (Imagine a toolbox that told you
off for using the wrong screwdriver!)

I believe that's almost 100% wrong. A programming language that doesn't
try to make better programmers ends up enabling poor programming practices,
which ends up producing poor programs. That results in programs and web
sites that crash, which brings on a bad reputation for programmers in
general.

PHP is a great example. It is possible to write good programs in PHP, but
it's also very, very easy to write bad programs in PHP. The result is that
most of the PHP samples you find on the web are absolute crap -- delicate,
unsafe, unmaintainable. The programmers don't realize this, and so the
crap reproduces like a virus.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

I wouldn't claim to be a good programmer, but I'm certainly a knowledgable one and that in large part because I've worked with languages which did their best not to get in my way. That has certainly resulted in some hideous abominations at various times but each of these has been deeply instructive and subsequent reflection has helped advance my knowledge and improve my instincts. Had I pursued the safer course and languages which insist on particular orthodoxies my coding life would have definitely been much poorer.

Or to stick with your analogy: whilst it's true that a philips screwdriver happens to be a very good fit for a philips head screw, in the absence of that screwdriver it's better to know how to use another tool to achieve the same effect than to sit there worrying about how inappropriate your tools are. After all no toolbox can ever have every tool you might need, and the more tools contained in the toolbox the more knowledge is required before you can start using any of them competently.

Ellie

Eleanor McHugh
Games With Brains
twitter: @feyeleanor

···

On 29 Nov 2010, at 04:40, Tim Roberts wrote:

Shadowfirebird <shadowfirebird@gmail.com> wrote:

Ruby: "There is more than one way to do it."
Python: "There should be one - and preferably only one - obvious way to
do it."

Programming languages -- at least, good programming languages -- shouldn't
try to make programmers into better programmers, or force them to work in
a certain way in order to get results. (Imagine a toolbox that told you
off for using the wrong screwdriver!)

I believe that's almost 100% wrong. A programming language that doesn't
try to make better programmers ends up enabling poor programming practices,
which ends up producing poor programs. That results in programs and web
sites that crash, which brings on a bad reputation for programmers in
general.

PHP is a great example. It is possible to write good programs in PHP, but
it's also very, very easy to write bad programs in PHP. The result is that
most of the PHP samples you find on the web are absolute crap -- delicate,
unsafe, unmaintainable. The programmers don't realize this, and so the
crap reproduces like a virus.

A toolbox certainly OUGHT to tell me off if I try to unscrew a slotted head
screw with a Philips screwdriver, if that saves me from taking a chunk out
of my hand as I do it.

----
raise ArgumentError unless @reality.responds_to? :reason

hi,
saw this on twitter today:

where he was making a point that "it sure is complicated for a
language having one way of doing things"

It is good to have multiple options, find the best solution to a
problem by applying common sense and good taste, take feedback/
benchmark and iterate.

Not really sure how the python zen works. Maybe having no choice in
indentation, multi-line lambdas etc are obvious. i dunno. If it comes
with experience and then it is no better than having options and
discovering the best option through experience, irc, mail-group,
benchmarks, awesome community, pretty ok docs and your own common
sense and good taste.

cheers,
deepak

···

On Nov 29, 2:57 pm, Robert Klemme <shortcut...@googlemail.com> wrote:

On Mon, Nov 29, 2010 at 5:40 AM, Tim Roberts <t...@probo.com> wrote:
> Shadowfirebird <shadowfireb...@gmail.com> wrote:

>>> Ruby: "There is more than one way to do it."
>>> Python: "There should be one - and preferably only one - obvious way to
>>> do it."

>>Programming languages -- at least, good programming languages -- shouldn't
>>try to make programmers into better programmers, or force them to work in
>>a certain way in order to get results. (Imagine a toolbox that told you
>>off for using the wrong screwdriver!)

> I believe that's almost 100% wrong. A programming language that doesn't
> try to make better programmers ends up enabling poor programming practices,
> which ends up producing poor programs. That results in programs and web
> sites that crash, which brings on a bad reputation for programmers in
> general.

> PHP is a great example. It is possible to write good programs in PHP, but
> it's also very, very easy to write bad programs in PHP. The result is that
> most of the PHP samples you find on the web are absolute crap -- delicate,
> unsafe, unmaintainable. The programmers don't realize this, and so the
> crap reproduces like a virus.

After all those years I am unsure how big the impact of a language is.
What I'd consider facts (in no particular order):

1. A programming language can do little to nothing to help you decide
how you lay out functionality across program code artifacts
(functions, procedures, methods, classes). But this (along with
naming of things) has a dramatic impact on readability and
reusability.

2. Good libraries which enforce particular usage patterns can do a
great deal to guide their users to a proper code structure. - But they
cannot prevent creating a mess if one tries to.

3. A key factor for writing good code is the person doing the writing.
People not interested to learn or otherwise improve their work are
unlikely to write better code. The same holds for people who do not
have a chance to improve because they are constantly buried under
loads of work since they lack the time needed for reflection.

4. Removing obstacles to writing good code (compare for example Ruby's
OO with Perl's) certainly helps people writing better code.

My 0.02 EUR.

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/

Eleanor McHugh wrote in post #965090:

...the more tools contained in the toolbox the
more knowledge is required before you can start using any of them
competently.

I don't think that is logically correct. As long as you can use some
tools, it is irrelevant whether there are others in the box, as long as
when you want to use your tools nobody else has removed them.

The analogy however is fundamentally flawed. Programming is different to
other areas of human endeavour. You can botch things with entirely the
wrong tool and the magic of computer chips covers the whole thing up.
You may just notice slower performance, more memory usage etc but
chances are you won't.

If Ruby gives you more tools, so that two different artisans appear to
be doing quite different things when they are actually trying to achieve
the same ends, the impacts are only likely to arise when other people
start to look at the code later. That problem however started many
decades before Ruby and Python arrived on the scene.

A better analaogy is when you buy a box of assorted chocolates because
there are a couple that you really love but can't buy by the bag.
Normally you can't afford to buy confectionary and waste it but Ruby is
free. So all that matters is whether you get the items you're after.

···

--
Posted via http://www.ruby-forum.com/\.