Deciding between ruby and python

Ville Vainio wrote:

I would like to suggest people take a look at a quite independent
comparison page at:

http://userlinux.com/cgi-bin/wiki.pl?RubyPython

Instead of the ancient page, comparing ancient version of ruby with an
ancient version of Python that Ruby people like to refer people to.

I’m prepared to admit you are right, since I don’t know Python.

But the first thing that struck me on this page was:

file, length, name, title = [’ ‘.join(t.split()) for t in
line.split(’|')]

This seems neither OO nor functional style to me. What do you think?

Hal

definedly a cow. horse burgers are terrible.

-a

···

On Tue, 30 Mar 2004, Gawnsoft wrote:

On Tue, 30 Mar 2004 00:02:23 GMT, Tim Hunter cyclists@nc.rr.com
wrote (more or less):

On Mon, 29 Mar 2004 19:05:03 +0200, Serve Lau wrote:

Wasn’t python designed with ease of use as top priority? Surely there
must be some differences there? Easier to express things in ruby, more
power or something?

Ruby-ists, IMO, are generally reluctant to make qualitative statements
about Python vs. Ruby. Partly this is because we’re inherently
non-confrontational :slight_smile: Partly this is because we’ve been burned by the
occasional troll who always starts out with mild Python vs. Ruby
questions. Partly because it’s near-impossible to define “better” such
that everybody agrees.

Yes - it’s a lot like saying “I’m looking for a large quadruped. Is a horse
or a cow better?”

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================

Hello Phil,

Tuesday, March 30, 2004, 3:09:25 AM, you wrote:

In article <112914078.20040330014722@scriptolutions.com>,

Hello Serve,

Monday, March 29, 2004, 10:04:25 PM, you wrote:

"Lothar Scholz" <mailinglists@scriptolutions.com> wrote in message
news:41663875.20040328202116@scriptolutions.com...

Hello Serve,

Sunday, March 28, 2004, 3:44:25 PM, you wrote:

> I'm trying to decide to learn either python or ruby. Are there

fundamental

> differences between them?

No, there aren't any fundamental difference. From an educational point
they the same, also not different from perl or tcl.
Imperative script languages with OO extensions.

Wasn't python designed with ease of use as top priority? Surely there must

No i don't think that python has such a top priority. It came from a
mathematical branch of a dutch university. Perl had a top priority in
extracting data from text files, and TCL had the top goal of making it
easy to embedd in C applications. Ruby is as useable for extracting
data as Perl now, but nobody else reached the TCL/TK level of ease of
embedding, you can do this in 2 lines in TCL but need a few duzend in
Ruby - thats the reason why TCL is still so popular (a magnitude more
popular then Ruby) and TCL is in my experience still the most advanced
scripting language (with the technically best GUI Toolkit) - even
better then Perl.

TCL the most advanced scripting language

No other language has complete separate multiple interpreters in the
core, almost perfect Unicode handling and a way of doing multithreading
that give you the advantage of modern CPU's (multicore CPU's which is
definetely the future). Yes it's slower and it is procedural and not
good for advanced datastructures. But this doesn't matter because it
always makes clear that it is a scripting language.

Python and Ruby say that they are a general purpose language. They can
be used like this, but i doubt that they are good general purpose
language, because they are very very slow (around 100 to 300 times) for a
lot of tasks.

and TK 'technically the best GUI
Toolkit'?! Well I guess YMMV(AL) (Your Milage May Vary (A Lot)) :wink:

Yes it still is. It is not looking well and it doesn't support some
widgets that are now standart. But TK is the only toolkit that has a
really working and customizeable event loop. QT,GTK,FOX,FLTK they all
miss this feature. It has the best layout managers (try to find
something like the grid layout manager), the same level of unicode
awareness then QT and the best event handling (callback system) that was ever
implemented in a toolkit. Simply try to bind the Hotkey "Control-E
Control-E Mouse-Button-Down" to a procedure in another toolkit :slight_smile:

But i must say that i did not do any programming in the last 3 years
with TCL. Instead i moved to PHP, Python and Ruby (and Java,Eiffel,C,C++).
All of them have much better language concepts but none of them has
reached the implementation quality that TCL reached 3 years ago.

···

Lothar Scholz <mailinglists@scriptolutions.com> wrote:

--
Best regards,
Lothar mailto:mailinglists@scriptolutions.com

Hi,

Hal Fulton wrote:

But the first thing that struck me on this page was:

file, length, name, title = [’ ‘.join(t.split()) for t in
line.split(’|')]

This seems neither OO nor functional style to me. What do you think?

Right, it’s doesn’t seem to be either. What I immediately thought was
this: “It looks bit like that other language…”

Happy rubying (or pythoning or even perling…)
Stephan

I’m prepared to admit you are right, since I don’t know
Python.

That’s a commendable attitude.

> file, length, name, title = [' '.join(t.split()) for t in
> line.split('|')]

> This seems neither OO nor functional style to me. What do you
> think?

Funny, because it’s very much both. join and split are string methods,
and the overall structure is a List Comprehension.

List comprehension is like

[ i+1 for i in [1,2,3] ]

which yields the list

[2,3,4]

List comprehensions come from Haskell (www.haskell.org) which is
considered a functional language, at least where I come from ;-).

···


Ville Vainio http://tinyurl.com/2prnb

And tcl has a lovely vfs implementation in the core :) (hint! hint!)
···

il Tue, 30 Mar 2004 15:01:59 +0900, Lothar Scholz mailinglists@scriptolutions.com ha scritto::

TCL the most advanced scripting language

Lothar Scholz wrote:

TCL the most advanced scripting language

No other language has complete separate multiple interpreters in the
core, almost perfect Unicode handling and a way of doing multithreading
that give you the advantage of modern CPU’s (multicore CPU’s which is
definetely the future). Yes it’s slower and it is procedural and not
good for advanced datastructures. But this doesn’t matter because it
always makes clear that it is a scripting language.

What is it about a “scripting” language that obviates their need for
speed, non-procedural constructs, or the ability to handle advanced
datastructures, exactly?

Ville Vainio wrote:

“Hal” == Hal Fulton hal9000@hypermetrics.com writes:

> I'm prepared to admit you are right, since I don't know
> Python.

That’s a commendable attitude.

> file, length, name, title = [' '.join(t.split()) for t in
> line.split('|')]

> This seems neither OO nor functional style to me. What do you
> think?

Funny, because it’s very much both. join and split are string methods,
and the overall structure is a List Comprehension.

I’d have thought t.split.join(’ ') would better exemplify
both OO and FP.

Hal

In article cdki60tqbdcr8bjfglaq3a9ijdv7ves4kk@4ax.com,

TCL the most advanced scripting language

And tcl has a lovely vfs implementation in the core :) (hint! hint!)

does vfs == “virtual file system” ? Meaning that you can access a URL
just the same way you would access a file on your system?

If that’s what you mean, here’s an excerpt from Why’s “What’s shiny and
new in 1.8”:

open-uri

I have been dying for this library to come up in the standard library.
Most of you don’t know it, but you can quit using Net::HTTP and Net::FTP.
The open-uri library is a Ruby equivalent to wget or curl (the library
mentioned in the previous section).

Basically, this module allows you to use the basic open method with URLs.

require ‘open-uri’
require ‘yaml’

open( “http://www.whytheluckystiff.net/why.yml” ) do |f|
feed = YAML::load( f )
end

Phil

···

gabriele renzi surrender_it@remove.yahoo.it wrote:

il Tue, 30 Mar 2004 15:01:59 +0900, Lothar Scholz >mailinglists@scriptolutions.com ha scritto::

I’d have thought t.split.join(’ ') would better exemplify
both OO and FP.

’ '.join(sequence) tends to get some bad rep, but I think it’s more OO
of the two. After all, general sequences should not have an operation
of “join elements with strings”, because it doesn’t make sense for
e.g. a sequence of sockets, while for a string it’s reasonable to
provide an operation that joins a sequence of string with itself
(because it can expect the sequence to be that of strings).

That is, string can know about sequences, but a sequence, being a more
general data type, should not know about strings.

As far as FP goes, allowing t.split w/o () is extremely non-FP,
because you lose first class functions. And FP without first class
functions is, well, Java.

···


Ville Vainio http://tinyurl.com/2prnb

does vfs == “virtual file system” ?

yes

Meaning that you can access a URL
just the same way you would access a file on your system?

yes I’m aware of open-uri and I do agree it is impressive and useful,
but, it has the problem of just being… well… ‘open’ :slight_smile:
For example, it does not allow handling of Dir objects out of the local fs.

A true vfs layer should allow stuff like this:
ruby -r vfs -run cp – -r ~/works/myweb ftp://user:pass@myserver/home/myid/public_html

More, it should allow to us to plug modules to handle
everything like zip, bzip2, sftp and so on.

(I’m not sure tclvfs does this, but I believe it should).

For an example of what I’m talking about take a look at GnomeVFS
(yes, we can use it from ruby :), or at libvfs that is on RAA
(the former example came from that).

I believe something like this in the base distribution would be lovely :slight_smile:

···

il 30 Mar 2004 17:55:25 GMT, ptkwt@aracnet.com (Phil Tomson) ha scritto::

Ville Vainio wrote:

“Hal” == Hal Fulton hal9000@hypermetrics.com writes:

> I'd have thought t.split.join(' ') would better exemplify
> both OO and FP.

’ '.join(sequence) tends to get some bad rep, but I think it’s more OO
of the two. After all, general sequences should not have an operation
of “join elements with strings”, because it doesn’t make sense for
e.g. a sequence of sockets, while for a string it’s reasonable to
provide an operation that joins a sequence of string with itself
(because it can expect the sequence to be that of strings).

That is, string can know about sequences, but a sequence, being a more
general data type, should not know about strings.

I’d have to disagree. join, since it produces a string, obviously
knows about strings even though it is not a string method.

As for x.y, I think it general we are “performing operation y on
object x” – and it seems clear to me that join is NOT acting on
’ ’ (which is only a single item anyway).

As far as FP goes, allowing t.split w/o () is extremely non-FP,
because you lose first class functions. And FP without first class
functions is, well, Java.

I don’t know FP either, but I thought method chaining was an important
part of it. Because of the disconnect I mentioned earlier (where join
is not actually acting on its receiver), the previous example doesn’t
show true method chaining.

As for the parens: I’ve never missed first class functions in Ruby.
Maybe I should. But I prefer the uniform access principle if I have to
choose between that and fcf.

Let’s channel this discussion more productively: Why should I want
first-class functions? Honest question, no sarcasm.

Hal

In article jgmj60lih3807ibu6rhjkhn5ab9fiac7k0@4ax.com,
gabriele renzi surrender_it@rc1.vip.ukl.yahoo.com writes:

yes I’m aware of open-uri and I do agree it is impressive and useful,
but, it has the problem of just being… well… ‘open’ :slight_smile:
For example, it does not allow handling of Dir objects out of the local fs.

open-uri.rb and pathname.rb provides a VFS for HTTP, FTP and local
files. Since they define a polymorphic open method for URI::HTTP,
URI::FTP and Pathname, you can open them as http_uri.open,
ftp_uri.open or pathname.open. You don’t need to distinguish them.
Note that Kernel.open(loc) is implemented as URI.parse(loc).open in
open-uri.rb.

If you want to open another kind of resources, define a class to
represent its location and define open method for the class. Then,
you can open the resource.

This means that Tcl’s struct Tcl_Filesystem is represented as a duck
type. Tcl Improvement Proposals: TIP 17: Redo Tcl's filesystem

However open-uri.rb and pathname.rb provides only two porlymorphic
methods: open and read. So it needs more methods to be useful as VFS.
For example, already Pathname#each_entry exists for iterating over
child entries like Dir.foreach. URI::FTP#each_entry should be
provided in future. URI::HTTP#each_entry is difficult to implement,
though. So I think the duck type is enough as a VFS framework.

I believe something like this in the base distribution would be lovely :slight_smile:

open-uri.rb and pathname.rb is in the base distribution.

···


Tanaka Akira

I’d have to disagree. join, since it produces a string, obviously
knows about strings even though it is not a string method.

And hence, the sequence knows about strings. The Ruby approach is
making a special case of strings, while the Python approach doesn’t.

I’m not saying this is a question of big importance - we have lots of
people in Python camp who don’t like ‘’.join() either. It just seems
most sensible for me, even if it isn’t obvious for newbies. I think
it’s a situation where Python errs on the side of pure OO instead of
practicality.

> As for x.y, I think it general we are "performing operation y
> on object x" -- and it seems clear to me that join is NOT
> acting on ' ' (which is only a single item anyway).

But that’s context dependent knowledge. Python is very explicit and
always requires () which is a ‘call’ operation on an object. I think
that’s a very small price to pay for first class functions.

> I don't know FP either, but I thought method chaining was an
> important part of it. Because of the disconnect I mentioned
> earlier (where join is not actually acting on its receiver),
> the previous example doesn't show true method chaining.

Yes, but join is an isolated special case. We get to chain all the
time in Python too. Join would have been added as a method for
sequences already if it was deemed critical - believe me, there have
been heated discussions. So far, I think we’ve been doing the right
thing.

> As for the parens: I've never missed first class functions in
> Ruby.  Maybe I should. But I prefer the uniform access
> principle if I have to choose between that and fcf.

But you don’t know that yet :). What practical benefits do you get
from the uniform access principle, and what do you mean by it?

> Let's channel this discussion more productively: Why should I want
> first-class functions? Honest question, no sarcasm.

You can just pass functions directly to anything that wants a callable
object. Functions and methods are objects like everything else, you
can pass them around and store them any way you want.

You can use higher order functions, which is critical for FP.

Check out Functional Programming in Python article series at

if you want to learn more (the article has links to parts 1 and 2).

BTW, I don’t consider first class functions anything “special”, it’s
just a logical result of the everything-is-an-object paradigm.

Alex Martelli really says most there is to say about comparing Ruby
and Python in the usenet article that was linked to in the UserLinux
comparison page, but here it is again:

http://groups.google.com/groups?selm=bhqr78021hp%40enews1.newsguy.com

···


Ville Vainio http://tinyurl.com/2prnb

Hal Fulton wrote:

Ville Vainio wrote:

That is, string can know about sequences, but a sequence, being a more
general data type, should not know about strings.

I’d have to disagree. join, since it produces a string, obviously
knows about strings even though it is not a string method.

I think Ville means that making join a method on a list means that lists
must now know about strings. Unfortunately, removing join as a list
method still leaves lists knowledgeable about string for every object
implements a to_s method.

In fact, knowing nothing but that to_s exists, you can write join like
this …

 def join(delimit)
   inject { |a, b| a.to_s + delimit + b.to_s }
 end

I have also heard (on c.l.py) that one reason the " ".join() form was
chosen was to allow join to be polymorphic on string type. This would
allow join to be implemented differently in subclasses of string (such
as a UnicodeString class perhaps). Since join can be defined in terms
of existing list methods (as we did above), there is no need to make
polymorphic on lists or sequences.

However, making join a string method is neither necessary nor sufficient
for a polymorphic behavior string subclass to be used.

For me, the big reason to make join a method in list is readability.
Allowing methods chains that read linearly left to right is a big plus,
overriding the other considerations in this case. (YMMV)

BTW, neither form is “more OO” than the other.

As far as FP goes, allowing t.split w/o () is extremely non-FP,
because you lose first class functions. And FP without first class
functions is, well, Java.

I don’t know FP either, but I thought method chaining was an important
part of it. Because of the disconnect I mentioned earlier (where join
is not actually acting on its receiver), the previous example doesn’t
show true method chaining.

Neither Ruby nor Python are functional languages, however both exhibit
some features that are found in function languages.

When people think of features of functional languages, they primarily
refer to two features in particular ..

(1) Stateless programming
(2) Higher order functions

Stateless programming means writing code that calculates a result
without changing the state of the program as it executes. This style of
programming has many advantages, but neither Ruby nor Python adheres to
this style, except in small snippets of code.

A functional language treats functions as first class data. This means
that functions can be passed about as data, and that operations can be
performed on these functions that produce new functions. A higher order
function (in my perhaps flawed understanding) is a function that takes
other functions as operands.

Here’s a concrete example … Suppose you had a function f(x,y) that
returns the value x+y. Now write a another function curry(f,n) that
returns a brand-new function object. This new function should take one
argument (x) and return the value x+n (where n was the value passed to
curry).

If your language can write functions like curry, then you have first
class functions and higher order functions. And this can be done in
both Ruby and Python.

[… from an earlier message …]

actually, I tend to think Ruby’s OO
is crippled by not having functions as first class objects.

I find it interesting when people claim that Ruby has no first class
functions, mostly because Ruby doesn’t have functions in the first
place. What looks like functions are really methods on objects.
Methods exist inside an object and like the proverbial quark, are never
seen outside of an object. Unlike functions which are explicitly
called, methods are always invoked by an object in response to receiving
message consisting of a message selector and a list of arguments.
Sometimes we abbreviate and pretend we are calling functions, but it is
still objects, methods and messages[1].

Question: If Ruby methods aren’t function, how can we do functional
programming?
Answer: With a poor man’s function!

At this point it is useful to quote Anton van Straaten where he sums up
his own enlightenment with these koan (see http://tinyurl.com/2m7p9):

 The venerable master Qc Na was walking with his student, Anton.
 Hoping to prompt the master into a discussion, Anton said "Master, I
 have heard that objects are a very good thing - is this true?" Qc Na
 looked pityingly at his student and replied, "Foolish pupil -
 objects are merely a poor man's closures."

 Chastised, Anton took his leave from his master and returned to his
 cell, intent on studying closures. He carefully read the entire
 "Lambda: The Ultimate..." series of papers and its cousins, and
 implemented a small Scheme interpreter with a closure-based object
 system. He learned much, and looked forward to informing his master
 of his progress.

 On his next walk with Qc Na, Anton attempted to impress his master
 by saying "Master, I have diligently studied the matter, and now
 understand that objects are truly a poor man's closures." Qc Na
 responded by hitting Anton with his stick, saying "When will you
 learn? Closures are a poor man's object." At that moment, Anton
 became enlightened.

If objects are a poor man’s closure, they certainly can be a poor man’s
function as well. In Ruby, we use objects as functions. Any object
that responds to the call message can be used, but by far the most
common functional object is the Ruby Proc/Lambda object.

Here’s the curry operation mentioned above, but done with first class
function objects in Ruby.

f = lambda { |x, y| x + y }
curry = lambda { |f, n|   lambda { |x| f.call(n, x) } }
g = curry.call(f, 2)
g.call(3)   #=> 5

In summary:

o “def” defines a method, not a function, first class or otherwise.
o What looks like a function call is really a message send to an object.
o Ruby uses objects for its functional programming. Since the function
is an object, calling it involves a normal object-style message using
“call” as the message selector.

I’ll close with this thought. Ruby and Python are perfect examples of a
duality between functions and objects. Where Ruby begins with objects
and builds functions out of them, Python begins with functions and
builds objects out of them. And what is really surprising is that
despite the rather fundamental differences in their semantic foundation,
the languages are more alike than they are different!

···


– Jim Weirich jim@weirichhouse.org http://onestepback.org

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

[1] I’m not trying to imply that all method invocations involve the
reification of a message. In fact, I have little knowledge of what
goes on under the covers in the C implementation. I’m only saying
that obj.method is semantically equivalent to obj.send(:method).

As for the parens: I’ve never missed first class functions in
Ruby. Maybe I should. But I prefer the uniform access
principle if I have to choose between that and fcf.

But you don’t know that yet :). What practical benefits do you get
from the uniform access principle, and what do you mean by it?

I believe he talks about accessor methods.
(I know that as of actual python you can use property() )
BTW I love to avoid parenthesis when it allows me to make stuff look
like syntax, say:

class My
private
def private_method
end
end

private is actually a method call.

You can just pass functions directly to anything that wants a callable
object. Functions and methods are objects like everything else, you
can pass them around and store them any way you want.

You can use higher order functions, which is critical for FP.

well, you can use HOF in ruby too, cause you can have Method objects
or Proc (lexical closures) objects.

You just need to create them explicitly.

It’s worth noting that near every place where you use a lambda or a
generic function argument in python, you use blocks in ruby, so
actually there are functional arguments everywhere in ruby, they just
look different :slight_smile:

IBM Developer

if you want to learn more (the article has links to parts 1 and 2).

I liked all the functional stuff from David Mertz. I loved usage of
HOF in text processing in python, but just to point out some
functional ruby stuff:
http://www.ping.de/~flori/ruby/programs/functional.html

ruby is an infix dialect of lisp :wink:

···

il 01 Apr 2004 23:59:59 +0300, Ville Vainio ville@spammers.com ha scritto::

Ville Vainio ville@spammers.com writes:

And hence, the sequence knows about strings. The Ruby approach is
making a special case of strings, while the Python approach doesn’t.

I’m not saying this is a question of big importance - we have lots of
people in Python camp who don’t like ‘’.join() either. It just seems
most sensible for me, even if it isn’t obvious for newbies. I think
it’s a situation where Python errs on the side of pure OO instead of
practicality.

It’s not String-specific; it calls the elements’ #to_s methods, and
joins the result.

I don’t see how this makes it any more “un-OO” than #sort, e.g., which
requires the elements to be comparable (in fact, comparable with each
other
), or do you have issues with that too?

I think Ville means that making join a method on a list means
that lists must now know about strings. Unfortunately,
removing join as a list method still leaves lists
knowledgeable about string for every object implements a to_s
method.

I mostly meant that the sequence has a special case for the list of
strings. We have str in Python too, but ‘’.join doesn’t call it:

‘-’.join([12,13])
Traceback (most recent call last):
File “”, line 1, in ?
TypeError: sequence item 0: expected string, int found

Calling to_s() seems kinda brutal from the Python POV. Perhaps this is
one of the areas where Ruby chooses the follow the Perl school of
Convenience.

> BTW, neither form is "more OO"  than the other.

And more importantly, “more OO” isn’t the end-all and be-all of good
design.

> Stateless programming means writing code that calculates a
> result without changing the state of the program as it
> executes.  This style of programming has many advantages, but
> neither Ruby nor Python adheres to this style, except in
> small snippets of code.

Yes, typically. That’s because neither optimizes the tail recursion to
a constant space operation.

> A functional language treats functions as first class data.  This means 

Yes, and Python does too.

> performed on these functions that produce new functions.  A
> higher order function (in my perhaps flawed understanding) is
> a function that takes other functions as operands.

… or returns new functions.

> builds objects out of them.  And what is really surprising is
> that despite the rather fundamental differences in their
> semantic foundation, the languages are more alike than they
> are different!

Yes, Ruby and Python are not all that different. I guess most Ruby
fanatics would be quite happy with a forked version of Python. Adding
most of the features Ruby people love would be quite easy (some, like
sequence.join would be trivial), it’s just that the core Python
developers have chosen not to implement them for one reason or
another.

···


Ville Vainio http://tinyurl.com/2prnb

Hi,

I get the feeling I may be feeding a troll, but some of your comments
left me feeling unable to resist replying, though I probably should
ignore.

> I'd have to disagree. join, since it produces a string, 

obviously
> knows about strings even though it is not a string method.

And hence, the sequence knows about strings. The Ruby approach is
making a special case of strings, while the Python approach doesn’t.

I’m not saying this is a question of big importance - we have lots of
people in Python camp who don’t like ‘’.join() either. It just seems
most sensible for me, even if it isn’t obvious for newbies. I think
it’s a situation where Python errs on the side of pure OO instead of
practicality.

No. When implementing a join method, you have a choice: let Strings
understand something about Arrays, or let Arrays understand something
about Strings. Does it make much difference either way? Should we
choose to make a special case of Strings, or Arrays?

I feel that it makes more sense tell an Array “join your elements using
this string” than the other way around. You feel differently. :slight_smile: I
guess it’s a matter of taste.

> As for x.y, I think it general we are "performing operation y
> on object x" -- and it seems clear to me that join is NOT
> acting on ' ' (which is only a single item anyway).

But that’s context dependent knowledge. Python is very explicit and
always requires () which is a ‘call’ operation on an object. I think
that’s a very small price to pay for first class functions.

As has been argued before, where pythoners will pass a function,
rubyists pass blocks. In the rare occasion where we want to pass a
method, there’s Method.new, which converts a block into a Method
object, or the instance_method method which lets you unbind a
pre-existing method. But for most things, we just use blocks. What’s so
special about using methods?

> Let's channel this discussion more productively: Why should I 

want
> first-class functions? Honest question, no sarcasm.

You can just pass functions directly to anything that wants a callable
object. Functions and methods are objects like everything else, you
can pass them around and store them any way you want.

see above…

You can use higher order functions, which is critical for FP.

again: blocks? Can you give an example where blocks don’t fill the spot
functions take in Python?

moving to another email (regarding calling to_s on array items when
joining:

I mostly meant that the sequence has a special case for the list of
strings. We have str in Python too, but ‘’.join doesn’t call it:

‘-’.join([12,13])
Traceback (most recent call last):
File “”, line 1, in ?
TypeError: sequence item 0: expected string, int found

Calling to_s() seems kinda brutal from the Python POV. Perhaps this is
one of the areas where Ruby chooses the follow the Perl school of
Convenience.

it makes perfect sense. Ruby uses duck typing… so when you call join,
it assumes that you want the array items interpreted as strings. It
calls to_s only to ensure that it has the proper concatenation methods
available. If the item doesn’t implement to_s, an error will be raised.
This isn’t a perlism, it’s good old-fashioned duck typing. (well, maybe
newfangled duck typing… I’m not sure :slight_smile:

> performed on these functions that produce new functions.  A
> higher order function (in my perhaps flawed understanding) is
> a function that takes other functions as operands.

… or returns new functions.

sorta like this? (remember, we use blocks here)

def combine_blocks(one, two)
Proc.new{|*args| one[ two[*args] ] }
end

this returns a new block that combines the two blocks passed.

Yes, Ruby and Python are not all that different. I guess most Ruby
fanatics

There’s only one fanatic plainly visible here…

would be quite happy with a forked version of Python. Adding
most of the features Ruby people love would be quite easy (some, like
sequence.join would be trivial), it’s just that the core Python
developers have chosen not to implement them for one reason or
another.

I think I caught a whiff of elitism there… Perhaps Pythoners would be
happy with a forked version of Ruby? I doubt it. And I doubt that
Rubyists want a forked version of Python.

just my two measly cents.

–Mark

···

On Apr 1, 2004, at 1:04 PM, Ville Vainio wrote:

I believe this is just like print.
Why output.print(string) over string.display(output)… and why not
display(output,string) or (out(str)).print or any other permutation of
points and parenthesis and words.

To everyone in the thread, please don’t forget that everything is
just a matter of taste. Peace & Love

PS
yeah… it’s just one of that days when… well…

···

il Fri, 02 Apr 2004 09:25:27 +1000, George Ogata g_ogata@optushome.com.au ha scritto::

I don’t see how this makes it any more “un-OO” than #sort, e.g., which
requires the elements to be comparable (in fact, comparable with each
other
), or do you have issues with that too?