Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Python vs Ruby!

Reply
Thread Tools

Python vs Ruby!

 
 
William James
Guest
Posts: n/a
 
      08-24-2005

The Pythonistas were asked to translate this Ruby code to Python:
print "Working..."; calc(); puts "finished."

This seemingly trivial task turned out to be quite thorny because
Guido frowns upon printing twice without intervening whitespace.

The first attempt by one of Guido's henchmen was a failure.
The second attempt was a failure. The third and fourth
were:

sys.stdout.write( "Working..."); calc(); print "finished."

print "working...", "" and calc(), "finished."


Guido has ways of making life unpleasant for those who refuse to do
as he says.


> If you really don't like even the space, you can do:


In other words, are you really sure you don't want to do it Guido's
way?
Better think twice! You know what happens when Guido is displeased!

This example leads one to believe that Guido's Python is almost
as ridgid, as inflexible, and as uncomfortable as a wooden shoe.
It also inspired this revision of Stephen Crane's poem:


Code as I Code

"Code as I code," said Guido,
"Or you are abominably wicked;
"You are a toad."

And after I had thought of it,
I said: "I will, then, be a toad."

 
Reply With Quote
 
 
 
 
gabriele renzi
Guest
Posts: n/a
 
      08-24-2005
William James ha scritto:
<snip>

notice that Guido himself considers print-the-keyword as an error and
wants to remove it ;P
 
Reply With Quote
 
 
 
 
bruno modulix
Guest
Posts: n/a
 
      08-24-2005
William James wrote:
> The Pythonistas were asked to translate this Ruby code to Python:
> print "Working..."; calc(); puts "finished."
>
> This seemingly trivial task turned out to be quite thorny because
> Guido frowns upon printing twice without intervening whitespace.
>
> The first attempt by one of Guido's henchmen was a failure.
> The second attempt was a failure. The third and fourth
> were:
>
> sys.stdout.write( "Working..."); calc(); print "finished."
>
> print "working...", "" and calc(), "finished."
>
>
> Guido has ways of making life unpleasant for those who refuse to do
> as he says.
>
>
>
>>If you really don't like even the space, you can do:

>
>
> In other words, are you really sure you don't want to do it Guido's
> way?
> Better think twice! You know what happens when Guido is displeased!
>
> This example leads one to believe that Guido's Python is almost
> as ridgid, as inflexible, and as uncomfortable as a wooden shoe.
> It also inspired this revision of Stephen Crane's poem:
>
>
> Code as I Code
>
> "Code as I code," said Guido,
> "Or you are abominably wicked;
> "You are a toad."
>
> And after I had thought of it,
> I said: "I will, then, be a toad."
>


William,

I'm sorry to have to say so, but you're acting like a complete toad
asshole.

Hopefully, I know enough of this communauty not to judge it on your
stupidity. Ruby has nothing to gain in bashing Python - nor Python in
bashing Ruby, but this is not the common attitude on c.l.py (AFAICT,
Ruby is usually considered as a very interesting language by most
pythonistas).

Get a life...


--
bruno desthuilliers
ruby -e "print '(E-Mail Removed)'.split('@').collect{|p|
p.split('.').collect{|w| w.reverse}.join('.')}.join('@')"
 
Reply With Quote
 
Nick Albright
Guest
Posts: n/a
 
      08-24-2005
<Laugh> Interesting perspective. Couple of thoughts. The only real
difference between the original ruby:

print "Working..."; calc(); puts "finished."

and the 3rd solution:

sys.stdout.write( "Working..."); calc(); print "finished."

Is changing puts to sys.stdout.write(). Which I don't know if is
such a large change/difference. Either way, you have to make two diff
print type calls to get it done.

I found more interesting your comment about why it's so hard. I
honestly took the adding of whitespace after a , in the python print to
be a design issue. It makes prining multiple things very handy, like:

print "Name", first, last

or

print "Pos", x, y, z

It elminiates the need for exta " " in the print line. The flip side
is that you obviously can't print one next to the other. But in your
example, is it really important that you get

Working...finished

vs:

Working... finished

?

If I really want percise output, I tend to use the formated print
anyways.

But to each their own. Just some misc thoughts from a guy passing
through, = )
-Nick

---
"We tend to scoff at the beliefs of the ancients. But we can't scoff at
them personally, to their faces, and this is what annoys me."

--Jack Handey

 
Reply With Quote
 
Greg McIntyre
Guest
Posts: n/a
 
      08-25-2005
Joe Van Dyk wrote:
> So, I think the question is: "Why would you
> want to use Ruby in a situation where Python is available?"


We use both here at work. Python for the actual project code
(management decision to adopt Python) and Ruby for
supporting/surrounding/supplemental/sysadmin type code.

I find Ruby distinctly better than Python for the following tasks:

- 1-liners from the command line (like you used to use Perl for)
- working with file system paths
- regular expression-intensive text processing
- XML templating (I love XTemplate xtemplate.sf.net & can't find
anything as good for Python)
- working with very large integers (Python 2.4 seems fixed though)
- extending basic types (Array, Hash vs. tuple, list, dict)
- package management (import/require/include, etc.)
- wrapping a C/C++ API (reference counting vs. mark & sweep)
- guessing the right method (homogenous naming scheme, etc.)
- generating internal documentation (RDoc >> pydoc)
- language customisation/metaprogramming

 
Reply With Quote
 
Joe Van Dyk
Guest
Posts: n/a
 
      08-27-2005
On 8/18/05, Joe Van Dyk <(E-Mail Removed)> wrote:
> Which is better, Python or Ruby?
>=20
> (ha, just kidding)
>=20
> I've been fighting the good fight inside a really large corporation
> trying to get Ruby on the "approved" list. I've brought this up a
> couple times in the past on this list and have got some good
> responses.


Well, good news. While Ruby's not on the companywide "approved" list
yet, my group and all other groups that we work with have got an
official "Ruby is ok" exception granted.

So, thanks to all of you!

Joe


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments