In search of a compelling reason to use ruby

i’m a python programmer, and I have recently been hearing a lot about
ruby. A lot of python people seem to think ruby is in some way inferior,
but I have yet to find any significant differences between the languages.
The only differences I have found so far have been superficial syntactic
things. The only real significant difference I have detected, is the
absence of a module system in ruby.

I would like to be able to make an objective and educated comparison. Ruby
seems to have a relatively small, but intensely devoted following.
Software that inspires such fervent support from a small community usually
possesses tremendous power that most people are just too dense to discern
(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time
to find out what it is that the fanatics find appealing.

I am looking for:
- examples of tangible features that ruby has, which python doesnt.
- examples of scenarios where some facet of, or property specific to
ruby contributed to the simplification or improvement of a programming
project.
- facets of the language which may not necessarily be useful, but are
notably creative/innovative.

Additionally, I realize that there is more to a language than its syntax
and functionality. As a result, I am also interested in hearing about
facets of the ruby community and ruby ideology, and anything else that
ruby programmers feel contribute to their affinity for the language.

I have a feeling that most of the things that make ruby worth using can
also be found in python. From the perspective a python programmer who has
taken only a precursory glance at ruby, it looks like ruby suggests a
functional style, while python suggests an imperative style. It also looks
like ruby may be better suited for quick shell scripts, whereas python is
better suited for bigger programs. I realize that I probably suffer from
misconceptions, and i’m looking forward to having them corrected.

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I am
better versed in the benefits!

Thanks in advance!
– SegPhault

I know Python only very cursory so I can’t comment very well on the
comparison. Some points strike me though:

“Ryan Paul” segphault@sbcglobal.net schrieb im Newsbeitrag
news:pan.2004.05.10.10.37.41.800624@sbcglobal.net

i’m a python programmer, and I have recently been hearing a lot about
ruby. A lot of python people seem to think ruby is in some way inferior,
but I have yet to find any significant differences between the
languages.
The only differences I have found so far have been superficial syntactic
things. The only real significant difference I have detected, is the
absence of a module system in ruby.

Maybe you overlooked that: there are modules in Ruby (which can be used
standalone as well as for mixin inheritance):

file foo.rb:

module Foo
def self.fact(n)
f = 1
for i in 2…n
f *= i
end
f
end
end

file bar.rb:

require ‘foo’
puts( Foo.fact( 10 ) )

For mixin look that documentation / usage of Enumerable.

I would like to be able to make an objective and educated comparison.
Ruby
seems to have a relatively small, but intensely devoted following.
Software that inspires such fervent support from a small community
usually
possesses tremendous power that most people are just too dense to
discern
(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time
to find out what it is that the fanatics find appealing.

I am looking for:
- examples of tangible features that ruby has, which python doesnt.
- examples of scenarios where some facet of, or property specific to
ruby contributed to the simplification or improvement of a
programming
project.
- facets of the language which may not necessarily be useful, but
are
notably creative/innovative.

Additionally, I realize that there is more to a language than its syntax
and functionality. As a result, I am also interested in hearing about
facets of the ruby community and ruby ideology, and anything else that
ruby programmers feel contribute to their affinity for the language.

I have a feeling that most of the things that make ruby worth using can
also be found in python. From the perspective a python programmer who
has
taken only a precursory glance at ruby, it looks like ruby suggests a
functional style, while python suggests an imperative style.

Here I’d say Ruby suggests an OO style.

One of the best things about Ruby is the block concept. Dunno whether
Python supports something similar.

def foo
100.times do |i|
yield i
end
end

foo do |x|
puts x
end

s = 0
foo {|y| s += y}
puts s

It also looks
like ruby may be better suited for quick shell scripts, whereas python
is
better suited for bigger programs. I realize that I probably suffer from
misconceptions, and i’m looking forward to having them corrected.

You probably derived that from the assumed fact of lacking module support.
In fact, Ruby is not suited for big programs because it makes writing big
programs hard by being concise and to the point. Often you need less code
than with other languages. :slight_smile: Dunno how Ruby compares to Python in this
aspect.

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I
am
better versed in the benefits!

No offense taken.

Regards

robert

On Monday, May 10, 2004, 8:43:57 PM, Ryan wrote, in part:

I am looking for:
- examples of tangible features that ruby has, which python doesnt.
- examples of scenarios where some facet of, or property specific to
ruby contributed to the simplification or improvement of a programming
project.
- facets of the language which may not necessarily be useful, but are
notably creative/innovative.

I suggest you take a look at Programming Ruby. It’s
a high-quality dead-tree textbook that’s freely readable online. It
assumes some decent background knowledge, which you obviously have.
The preface and the first couple of chapters will tell you most of
what you want to know, and from there you can pick out more advanced
things if you wish.

I certainly welcome discussions about particular features, but direct
Python/Ruby comparisons are very common on this list and almost always
generate more heat than light. That’s despite the best of intentions.
The reality is that it’s hard to think outside your own
experience/background. There’s no quick answer to your questions, as
I have found in the past. For the curious, learning Ruby is extremely
worthwhile, even if you never write a line of code in it. You will
learn some novel approaches, no matter what your background, as Ruby
draws from many languages.

But like I say, there’s no shortcut. If you spend an hour or so
reading the material in “Programming Ruby” (known fondly as “The
Pickaxe”), then you will understand much better where Ruby is coming
from and will (hopefully) start to appreciate some of its distinctive
features.

All the best,
Gavin

you better look at the many times debated stuff:
http://www.ruby-doc.org/RubyEyeForThePythonGuy.html
I believe with come patience you may get better and more complete
answer to anything by looking at old threads.

I am looking for:

  • examples of tangible features that ruby has, which python doesnt.

I believe the strongest one (and totally incompatible with python’s
call methods) is the usage of methods as syntax enhancer[1]

Say, when you type:

class Foo
private
def foo
end
end

you’re setting a state calling the private() method, not actually
using a keyword. This, toghether with blocks, allows
you to write stuff like this:

irb(main):001:0> def with(obj,&block)
irb(main):002:1> obj.instance_eval(&block)
irb(main):003:1> end
=> nil
irb(main):004:0> with 10 do
irb(main):005:1* print id
irb(main):006:1> end
21=> nil
irb(main):007:0> 10.id
=> 21

but, in the end, ruby and python evolved toward common features via
different approaches (i.e. python property() is similar in effects to
ruby accessor methods, even if completely different)

And one thing that I don’t see spotted in the oldest thread is ruby’s
SAFE levels (controlling stuff like tainted input, FS access, and so
on)

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I am
better versed in the benefits!

you’ve been kind enough to still be far from flaming :wink:

[1]
I can’t say we define new syntax in ruby, but it looks like we do :slight_smile:

···

il Mon, 10 May 2004 10:42:02 GMT, Ryan Paul segphault@sbcglobal.net ha scritto::

In article pan.2004.05.10.10.37.41.800624@sbcglobal.net,

i’m a python programmer, and I have recently been hearing a lot about
ruby.

Good.

A lot of python people seem to think ruby is in some way inferior,
but I have yet to find any significant differences between the languages.
The only differences I have found so far have been superficial syntactic
things. The only real significant difference I have detected, is the
absence of a module system in ruby.

?? absence of a module system in ruby? What do you mean by that? We’ve
got modules.

I would like to be able to make an objective and educated comparison. Ruby
seems to have a relatively small, but intensely devoted following.
Software that inspires such fervent support from a small community usually
possesses tremendous power that most people are just too dense to discern
(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time
to find out what it is that the fanatics find appealing.

I am looking for:

  • examples of tangible features that ruby has, which python doesnt.

Continuations, blocks.

  • examples of scenarios where some facet of, or property specific to
    ruby contributed to the simplification or improvement of a programming
    project.

Here’s one: Ruby’s code blocks. Deceptively simple, but very powerful in
practice. They allow you to easily create domain specific languages very
easily in Ruby.

Quick example: I’m taking a Quantum Computing class. The prof is looking
for a language for designing quantum circuits. I signed up for the
project and createed a ‘language’ I call QDL (Quantum Design Language),
but it’s reeally just plain Ruby under the covers - no parser needs be
created.

Here’s an example of QDL:

circuit = QCircuit {
QBits = 4
l0 = QLayer {
feynmann(0,3)
feynmann(1,2)
}
l1 = QLayer {
toffoli(2,3,0)
}
}

Basically this describes the structure of a simple quantum circuit with
two layers and 3 gates. It can be simulated. I can now have my
classmates write QDL without having to know anything about Ruby at all.
Of course, if they’re willing to learn a little Ruby it becomes much more
powerful since they can access all of Ruby from QDL.

The magic here is Ruby’s code blocks (the code between ‘{’ and ‘}’). They
can be passed around and ‘called’ or 'yield’ed to. I suspect it would be
very difficult to implement a QDL-like language in Python because Python
doesn’t have code blocks like this (you would have to create a parser).

(BTW: QDL is implemented in about 400 line of Ruby, that includes all the
additional matrix operations (Kronecker product) and some simple error
checking).

  • facets of the language which may not necessarily be useful, but are
    notably creative/innovative.

Additionally, I realize that there is more to a language than its syntax
and functionality. As a result, I am also interested in hearing about
facets of the ruby community and ruby ideology, and anything else that
ruby programmers feel contribute to their affinity for the language.

I have a feeling that most of the things that make ruby worth using can
also be found in python. From the perspective a python programmer who has
taken only a precursory glance at ruby, it looks like ruby suggests a
functional style, while python suggests an imperative style. It also looks
like ruby may be better suited for quick shell scripts, whereas python is
better suited for bigger programs. I realize that I probably suffer from
misconceptions, and i’m looking forward to having them corrected.

You can use Ruby for large projects as well. There are rumors of 20,000
to 30,000 line Ruby programs here. Personally, I don’t think I’ve written
anything that was more than ~5000 lines of Ruby - of course, in my
experience, 5K lines of Ruby packs about the same functionality as
20K to 25K lines of C++ code.

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I am
better versed in the benefits!

Mostly you need to try using Ruby on a small test project. Actually using
the language will give you a better feel for it than us telling you about
it.

Phil

···

Ryan Paul segphault@sbcglobal.net wrote:

I just wanted to thank everybody for the great responses. After going
through some of the links you folks provided, and reading through some
documentation, my curiosity has transformed into utter maniacal glee. Ruby
solves a lot of the problems I had with python. Blocks are particularly
enticing. I have spent a lot of time hacking around with python, trying to
abuse metaclasses so I could use the python parser for domain specific
languages. I’m delighted to find that ruby provides such an elegant
mechnaism to facilitate the task. Additionally, it looks like ruby’s
syntax is significantly more elegant than python, in many respects.

Now i’m going to port a bunch of my python code for practice! =D

Thanks again!!
–SegPhault

···

On Mon, 10 May 2004 10:42:02 +0000, Ryan Paul wrote:

i’m a python programmer, and I have recently been hearing a lot about
ruby. A lot of python people seem to think ruby is in some way inferior,
but I have yet to find any significant differences between the languages.
The only differences I have found so far have been superficial syntactic
things. The only real significant difference I have detected, is the
absence of a module system in ruby.

I would like to be able to make an objective and educated comparison. Ruby
seems to have a relatively small, but intensely devoted following.
Software that inspires such fervent support from a small community usually
possesses tremendous power that most people are just too dense to discern
(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time
to find out what it is that the fanatics find appealing.

I am looking for:
- examples of tangible features that ruby has, which python doesnt.
- examples of scenarios where some facet of, or property specific to
ruby contributed to the simplification or improvement of a programming
project.
- facets of the language which may not necessarily be useful, but are
notably creative/innovative.

Additionally, I realize that there is more to a language than its syntax
and functionality. As a result, I am also interested in hearing about
facets of the ruby community and ruby ideology, and anything else that
ruby programmers feel contribute to their affinity for the language.

I have a feeling that most of the things that make ruby worth using can
also be found in python. From the perspective a python programmer who has
taken only a precursory glance at ruby, it looks like ruby suggests a
functional style, while python suggests an imperative style. It also looks
like ruby may be better suited for quick shell scripts, whereas python is
better suited for bigger programs. I realize that I probably suffer from
misconceptions, and i’m looking forward to having them corrected.

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I am
better versed in the benefits!

Thanks in advance!
– SegPhault

Some general conclusions:

I’ve learned quite a bit more ruby, and i’ve ported a bit of python code
by hand for exercise, and I think I can now safely make some useful
generalizations about the differences between the two languages.

Python is simple and consistent, it promotes uniform style between
programs and programmers. Python also works very hard to prevent the
programmer from doing something that might make the language inconsistent,
and it’s design often enforces a clear, and concise imperative design.
Syntactic shortcuts and things like native regular expressions are
sacrificed to ensure maximum maintainability and readability.

Ruby is flexible and syntactically mutable. It allows programmers to alter
the behavior of the language itself in contexts where it may be beneficial
to do so. It promotes self extension and alteration, and it introduces a
lot of additional (largely optional) complexity that imbues the language
with the capacity to be, at times, rather arcane. In many cases, ruby
provides convenient syntactic shortcuts to automate things that would have
to be done manually in python.

Ruby idioms dont feel as instantly intuitive as python idioms, but they
seem a great deal more natural. I would definitely say that learning ruby
is a greater challenge than learning python. I would describe several
facets of ruby as ‘mind altering’.

Ruby’s OO is significantly better than python’s. Ruby promotes (and
practically implies) good OO techniques and methodology. This is mostly a
result of Ruby’s practice of making all instance variables private, and
the use of a rather elegant means of customizing variable access.

A few examples:

Blocks are a rather simple concept, but they are, initially, extremely
hard to understand, simply because there is nothing else like them. Python
does not provide any profoundly novel or innovative syntactic constructs,
so it easy for any object oriented programmer to grasp.

The axiomatic syntactic classes in python (lists, strings, integers) are
completely and totally immutable. Python does NOT allow you to change or
extend these classes in any way. This is done to ensure utter uniformity,
but it cripples the programmer immensely. Guido Van Rossum, in one of his
essays, says that python could easily support this feature, but he
intentionally chose to disallow it to ensure that programmers wouldn’t
accidentally break each others libraries, or the python base libraries for
that matter. Programming around ideology like that is like trying to carve
a sculpture with safety scissors.

In python, we have map, filter, and list comprehensions, all of which can
be used to manipulate lists in very general ways. In order to do certain
things, python users have to stack multiple functions into map statements.
Generally, this is actually pretty simple to do, and makes things somewhat
intuitive. In ruby, there are a multitude of rather oddly named array
functions that have very specific behaviors, most of which can be used
with blocks to concisely describe extremely sophisticated operations.

In conclusion, I feel that python, because of its steadfast consistency,
might be more appropriate for corporate applications, but for power
scripters, who need power and flexibility, nothing beats ruby. I’d like to
know if ruby supports something like C++ namespaces, because something
like that would probably vastly decrease the destructive potential of
inconsistency, without killing its usefulness. I’ve suggested such a
feature several times in the python world, but nobody seemed to see the
benefit.

–SegPhault

···

On Mon, 10 May 2004 10:42:02 +0000, Ryan Paul wrote:

i’m a python programmer, and I have recently been hearing a lot about
ruby. A lot of python people seem to think ruby is in some way inferior,
but I have yet to find any significant differences between the languages.
The only differences I have found so far have been superficial syntactic
things. The only real significant difference I have detected, is the
absence of a module system in ruby.

I would like to be able to make an objective and educated comparison. Ruby
seems to have a relatively small, but intensely devoted following.
Software that inspires such fervent support from a small community usually
possesses tremendous power that most people are just too dense to discern
(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time
to find out what it is that the fanatics find appealing.

I am looking for:
- examples of tangible features that ruby has, which python doesnt.
- examples of scenarios where some facet of, or property specific to
ruby contributed to the simplification or improvement of a programming
project.
- facets of the language which may not necessarily be useful, but are
notably creative/innovative.

Additionally, I realize that there is more to a language than its syntax
and functionality. As a result, I am also interested in hearing about
facets of the ruby community and ruby ideology, and anything else that
ruby programmers feel contribute to their affinity for the language.

I have a feeling that most of the things that make ruby worth using can
also be found in python. From the perspective a python programmer who has
taken only a precursory glance at ruby, it looks like ruby suggests a
functional style, while python suggests an imperative style. It also looks
like ruby may be better suited for quick shell scripts, whereas python is
better suited for bigger programs. I realize that I probably suffer from
misconceptions, and i’m looking forward to having them corrected.

I sincerely hope nobody finds any of my comments offensive, I dont mean
them as criticisms of ruby. I intentionally withhold criticisms until I am
better versed in the benefits!

Thanks in advance!
– SegPhault

Phil Tomson wrote:

Quick example: I’m taking a Quantum Computing class. The prof is looking
for a language for designing quantum circuits. I signed up for the
project and createed a ‘language’ I call QDL (Quantum Design Language),
but it’s reeally just plain Ruby under the covers - no parser needs be
created.

This is the same approach I used when writing a Build Control Language
to replace make. I used Ruby blocks to describe the actions associated
with tasks.

Example:

task :compile do |t|
java.compile t.source
end

By making making the entire build file Ruby code, I have an incredibly
powerful build language. This would have been much more clumsy without
the use of blocks.

···


– 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)

I just wanted to thank everybody for the great responses. After going
through some of the links you folks provided, and reading through some
documentation, my curiosity has transformed into utter maniacal glee. Ruby
solves a lot of the problems I had with python. Blocks are particularly
enticing. I have spent a lot of time hacking around with python, trying to
abuse metaclasses so I could use the python parser for domain specific
languages. I’m delighted to find that ruby provides such an elegant
mechnaism to facilitate the task. Additionally, it looks like ruby’s
syntax is significantly more elegant than python, in many respects.

Now i’m going to port a bunch of my python code for practice! =D

Hphew. That was fast and easy, wasn’t it? Glad you found solutions to
your problems so quickly.

···


Sascha Ebach Hexatex Holistic-Webdesign
Hugo-Junkers-Str. 26 50739 Köln
Web: http://www.hexatex.de mailto:se@hexatex.de
Tel: 0221 / 5994393 Fax: 0221 / 5994394

Ryan Paul wrote:

I just wanted to thank everybody for the great responses.

You’re welcome.

I have a favor to ask. I’m guessing that most people on this list know
Ruby far better than they do Python. The Ruby/Python comparison is a
recurring theme, and we try to collect resources (such as the Ruby Eye
For The Python Guy page) so folks don’t get callouses retyping the same
info. You being a Pythonista and all, I’d appreciate any comparisons
you can offer, or critiques of existing comparisons. There’s little
point in referring people to resources that misrepresent Python, or put
up straw man arguments.

Thanks,

James Britt

Ruby 2.0 will (probably) support selector namespaces. For more info:

I agree that there should be some flexible namespace mechanism to help
contain possible damage done by class redefinitions. It would be nice
to, say, allow an external script to change core classes without
worrying about it breaking someone else’s code (in a shared interpreter
context).

cheers,
–Mark

···

On May 12, 2004, at 9:38 AM, Ryan Paul wrote:

I’d like to
know if ruby supports something like C++ namespaces, because something
like that would probably vastly decrease the destructive potential of
inconsistency, without killing its usefulness. I’ve suggested such a
feature several times in the python world, but nobody seemed to see the
benefit.

> >In python, we have map, filter, and list comprehensions, all of which can >be used to manipulate lists in very general ways. In order to do certain >things, python users have to stack multiple functions into map statements. >Generally, this is actually pretty simple to do, and makes things somewhat >intuitive. In ruby, there are a multitude of rather oddly named array >functions that have very specific behaviors, most of which can be used >with blocks to concisely describe extremely sophisticated operations.

In ruby there are a lot of Enumerable functions, not array’s :slight_smile:
What method do you think is oddly named ?
I for one, would say inject() but using reduce() or fold() is equally
non intuitive for me :slight_smile:

···

il Wed, 12 May 2004 16:37:42 GMT, Ryan Paul segphault@sbcglobal.net ha scritto::

Hmm, that is an interesting comment about the corporate use of Ruby.
I considered the opposite…that python is too restrictive
and not generally compatible with peoples tastes
(especially the tab/indent issue and invisible ends) unlike Ruby,
which promotes good OO and generally liked by most people.

···

On Thursday, 13 May 2004 at 1:38:54 +0900, Ryan Paul wrote:

On Mon, 10 May 2004 10:42:02 +0000, Ryan Paul wrote:

In conclusion, I feel that python, because of its steadfast consistency,
might be more appropriate for corporate applications, but for power
scripters, who need power and flexibility, nothing beats ruby. I’d like to
know if ruby supports something like C++ namespaces, because something
like that would probably vastly decrease the destructive potential of
inconsistency, without killing its usefulness. I’ve suggested such a
feature several times in the python world, but nobody seemed to see the
benefit.

–SegPhault


Jim Freeze

“Ryan Paul” segphault@sbcglobal.net schrieb im Newsbeitrag
news:pan.2004.05.12.16.33.49.209896@sbcglobal.net

Ruby is flexible and syntactically mutable. It allows programmers to
alter
the behavior of the language itself

Well, not really. It just looks like you do. :slight_smile:

in contexts where it may be beneficial
to do so. It promotes self extension and alteration, and it introduces a
lot of additional (largely optional) complexity that imbues the language
with the capacity to be, at times, rather arcane. In many cases, ruby
provides convenient syntactic shortcuts to automate things that would
have
to be done manually in python.

Ruby idioms dont feel as instantly intuitive as python idioms, but they
seem a great deal more natural. I would definitely say that learning
ruby
is a greater challenge than learning python. I would describe several
facets of ruby as ‘mind altering’.

I can’t judge on learning Python, but I found learning Ruby quite easy
apart from some more sophisticated concepts (Continuations come to mind).

Ruby’s OO is significantly better than python’s. Ruby promotes (and
practically implies) good OO techniques and methodology. This is mostly
a
result of Ruby’s practice of making all instance variables private, and
the use of a rather elegant means of customizing variable access.

A few examples:

Blocks are a rather simple concept, but they are, initially, extremely
hard to understand, simply because there is nothing else like them.

Not in Python maybe (dunno) but in other languages. AFAIK you have them
in Smalltalk. And functional languages support a similar concept with
anonymous functions. That’s what blocks basically are. In Java you have
to define anonymous classes to do such things but Ruby blocks are far
easier to use because they integrate nicely with the language.

Python
does not provide any profoundly novel or innovative syntactic
constructs,
so it easy for any object oriented programmer to grasp.

Apart from the explicite naming of ‘self’ in method definitions which I
happen to find a bit and irritating, because it has to be provided in the
definition but not while using it.

The axiomatic syntactic classes in python (lists, strings, integers) are
completely and totally immutable. Python does NOT allow you to change or
extend these classes in any way. This is done to ensure utter
uniformity,
but it cripples the programmer immensely. Guido Van Rossum, in one of
his
essays, says that python could easily support this feature, but he
intentionally chose to disallow it to ensure that programmers wouldn’t
accidentally break each others libraries, or the python base libraries
for
that matter. Programming around ideology like that is like trying to
carve
a sculpture with safety scissors.

compatible ways (i.e. introducing new methods). Nobody want’s to step
into that trap. :slight_smile:

In python, we have map, filter, and list comprehensions, all of which
can
be used to manipulate lists in very general ways. In order to do certain
things, python users have to stack multiple functions into map
statements.
Generally, this is actually pretty simple to do, and makes things
somewhat
intuitive. In ruby, there are a multitude of rather oddly named array
functions that have very specific behaviors, most of which can be used
with blocks to concisely describe extremely sophisticated operations.

I love especially Enumerable#inject. Basically you can implement most
other methods in Enumerable by using #inject. It’s very powerful although
I’ll readily admit that it takes some time to grasp the concept.

In conclusion, I feel that python, because of its steadfast consistency,
might be more appropriate for corporate applications, but for power
scripters, who need power and flexibility, nothing beats ruby. I’d like
to
know if ruby supports something like C++ namespaces,

Modules can be and are in fact used for this often. You can reopen them
any time you like (as classes, too).

Thanks for your insights!

Kind regards

robert
···

From my experience, these standard classes are normally only extended in

task :compile do |t|
java.compile t.source
end

rolo writes:

What is this task…? a method…?

···

-----Original Message-----
From: Jim Weirich [mailto:jim@weirichhouse.org]

I’ve been taking a lot of notes while learning ruby, comparing the ruby
examples to python equivalents, and recording how both ruby and
python solve certain problems. I think I could probably clean up my notes
a bit, and restructure them into a relatively good comparison between the
languages. When I fill it out a bit more, i’ll make it publicly available,
and drop a link here and in comp.lang.python (where I will probably be
lynched for my impertinence). So far, most of the criticisms of ruby that
flourish in the python community are based on misconceptions. (for
instance, a lot of people seem to know that ruby only supports single
inheritance, but what they dont know is that the mixin system MORE than
makes up for it)

I also want to write parts of it like a cookbook so that python
programmers can see how ruby handles some of the specific things that are
commonly done with python. The idea of ‘switching languages’ is really
unnerving for a lot of programmers, and I think its really important to
illustrate just how minimal the learning curve is. Ruby feels almost like
a logical extension of python, with some pleasant perl tricks thrown in
for good measure.

Presentation is always an issue, and i’m still deciding what the best way
to express the information would be. If I started a conversation with a
python programmer saying something like “have you ever tried ruby? it does
some neat things!” they would probably scoff, but if I said “what if you
could do assignments in anonymous functions?” I might capture their
interest.

There is a growing community of python malcontents that might be
interested in ruby. They have a lot of really creative syntax ideas, most
of which are ignored by the mainstream python community. I think it would
be of benefit to the ruby community to be aware of some of their interests
and motivations. Some of those programmers might be interested in
contributing to ruby, rather than working on their own independent
python forks, if I can illustrate ways in which ruby meets their
individual needs. To that end, I will probably spend some time looking at
python derivatives to see where the divergences are, and how (if at all)
their python extensions compare to some of ruby’s development idioms.
‘Prothon’ is a good example of a python derivative on my list. I also mean
to show how ruby provides native support for many of the features hacked
into python by Xoltar’s partial, functional, and datastruct libraries.

Ultimately, i’m interested in a flexible and powerful interpreted
language, and what I have seen of ruby’s style indicates a progressive and
intuitive development paradigm that is bold enough to cast aside standards
and cliches to return the power to the user.

–segphault

···

On Tue, 11 May 2004 12:50:24 +0900, James Britt wrote:

Ryan Paul wrote:

I just wanted to thank everybody for the great responses.

You’re welcome.

I have a favor to ask. I’m guessing that most people on this list know
Ruby far better than they do Python. The Ruby/Python comparison is a
recurring theme, and we try to collect resources (such as the Ruby Eye
For The Python Guy page) so folks don’t get callouses retyping the same
info. You being a Pythonista and all, I’d appreciate any comparisons
you can offer, or critiques of existing comparisons. There’s little
point in referring people to resources that misrepresent Python, or put
up straw man arguments.

Thanks,

James Britt

Its not so much that their names are strange, its the fact that they exist
at all. In python, lists only have like 8 or 9 functions, and they are all
pretty standard and self explanatory (append, count, extend, insert,
remove, reverse, and maybe two or three others). Having things like
collect, replace, assoc, and compact built into arrays is something of a
novelty for a python programmer. I’m used to having to do replacement like
this, for example:
[y for x in listobj if x == z]

Personally, I feel that it is better to have functions that do these
things, because list comprehensions scale grotesquely, so I prefer the way
ruby does it. Not only does ruby provide a ton of useful functions to
start with, but I can add as many of my own as I want!

Also, the fact that collect doesnt automatically compact really threw me
for a spin. I was using “x.collect {whatever}.compact” until I figured out
that it is easier to do a reject on the inverse of what I would have put
in a python ‘filter’. I added a ‘filter’ function to the array class that
fixes this for me.

Additionally, having two different names for the same thing (eg: collect
and map) was initially confusing, but only because i’m not used to such
things. Python would NEVER do that.

–segphault

···

On Wed, 12 May 2004 18:04:17 +0000, gabriele renzi wrote:

il Wed, 12 May 2004 16:37:42 GMT, Ryan Paul segphault@sbcglobal.net > ha scritto::

> >In python, we have map, filter, and list comprehensions, all of which can >be used to manipulate lists in very general ways. In order to do certain >things, python users have to stack multiple functions into map statements. >Generally, this is actually pretty simple to do, and makes things somewhat >intuitive. In ruby, there are a multitude of rather oddly named array >functions that have very specific behaviors, most of which can be used >with blocks to concisely describe extremely sophisticated operations.

In ruby there are a lot of Enumerable functions, not array’s :slight_smile:
What method do you think is oddly named ?
I for one, would say inject() but using reduce() or fold() is equally
non intuitive for me :slight_smile:

gabriele renzi wrote:

What method do you think is oddly named ?
I for one, would say inject() but using reduce() or fold() is equally
non intuitive for me :slight_smile:

There are a really really nice name for it out there.

Unfortunately, collect are already used.

rolo wrote:

From: Jim Weirich [mailto:jim@weirichhouse.org]

task :compile do |t|
java.compile t.source
end

rolo writes:

What is this task…? a method…?

Yes, task is a method, :compile is a symbol being passed to the method task
as its first and only parameter, and do…end is the code block also passed
to the method task.

Curt

···

-----Original Message-----

rolo wrote:

From: Jim Weirich [mailto:jim@weirichhouse.org]

task :compile do |t|
java.compile t.source
end

rolo writes:

What is this task…? a method…?

Task is a method that takes an argument (the symbol :compile in this
example) and a block to be executed when the compile task is required.
A series of task declarations along with the appropriate dependencies
will describe how to build a project. When the rake program is
invoked, it loads the task declarations (which are just ruby code) and
determines the order of the tasks to be executed, then invokes the
proper blocks to build the system. Rake is smart enough to only invoke
a task if it is required, and to not invoke it more than once. It is
almost a direct replacement for make, but all in Ruby.

See http://rake.rubyforge.org/ for more details.

···

-----Original Message-----


– 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)