Cygwin/Ruby1.6.6

Status
Not open for further replies.

dockeen

Ars Tribunus Militum
1,600
You can tell I am getting old when my idea of a relaxing
time is to compile an interpreter that I don't even know how
to use yet...

Shortly after Christmas, my boss came in and said that he
had gotten two new toys for Christmas, a car and a computer.
I proceeded toa sk him about the computer. I never asked
him what the car was. Somebody, I think, needs to shoot me
and put me out of everyone elses misery :)

Wayne
 

Agathos

Ars Praefectus
3,558
Subscriptor
"Look at our previous argument on this matter, and read my points with special
emphasis." :D

Well, I just re-read that thread and I have to say I didn't find your points very convincing. They seemed to be personal: lots of "In my experience, in my opinion..." I may well have the same experience, but the only way to know for sure is to learn both Ruby and Python and write non-trivial code in both. Which I will probably do in time...
In the meantime, all I know is that in my dabbling, Ruby code has been pretty, readable, and fun to write.
 
D

Deleted member 5324

Guest
Originally posted by Agathos:
Well, I just re-read that thread and I have to say I didn't find your points very convincing. They seemed to be personal: lots of "In my experience, in my opinion..." I may well have the same experience, but the only way to know for sure is to learn both Ruby and Python and write non-trivial code in both. Which I will probably do in time...
In the meantime, all I know is that in my dabbling, Ruby code has been pretty, readable, and fun to write.

I don't quite know if we're referring to the same thread, since the thread I'm
referring to is on a different forum.

And given the Turing-completeness of every popular language out there, nothing
remains to compare languages technically except speed of implementation. The
important metrics, such as ease of code reuse, the quality of development
facilities, readability and maintainability of code, learning curve, etc. can
only be compared (and verified, as you noted) experimentally.

In the meantime, I can probably make another addition to my list of Ruby
complaints in the thread I posted at Linuxnewbie -- its implementation in C is
written poorly when compared to Python (which is one significant
reason why Python is making leaps and bounds while Ruby stands still -- why
Python is gaining things like coroutines and generators while Ruby isn't. It's
also very possibly a reason why there's only one implementation of Ruby, but at
least 4 implementations of Python.)

Jeremy
 
D

Deleted member 5324

Guest
Originally posted by dockeen:
Hasn't Python been around significantly longer that Ruby?

It depends on how you define "significantly." Python was first released in
1991; Ruby was first released in 1995. Work began on Python in 1990; it began
on Ruby in 1993.

If so, could some of the maturity of implementation issues be a matter of maturity and be expected to improve?

Of course, all implementation issues can be expected to improve as time goes on.
What I was noting, however, is that Python's implementation issues get resolved
faster, bugs get fixed quicker, and capabilities get added more easily because
its implementation is superior. It's more readable and more consistent, and by
those attributes more accessible to people who want to hack on it.
That's one of the reasons there are at least 4 implementations of Python, but
still only one implementation of Ruby.

Ruby, under the covers, still has the look and feel of a program written by a
single lone programmer, and while that's the case, it'll most likely stay that
way.

Jeremy
 

_klamath_

Ars Scholae Palatinae
770
Ruby, under the covers, still has the look and feel of a program written by a single lone programmer, and while that's the case, it'll most likely stay that way.

What parts of Ruby "under the covers" have this look and feel that you refer to? If you want to discuss the "cleanliness" of the internals of both languages, Python's seems to be much clumsier to me. For instance, the silly type/class distinction, the need to pass 'self' to every object method explicitely, the naming of lots of functions prefixed with '__' (rather than, say, access control), the mediocre C API, the duplicity of having both lists and tuples (when the functionality of tuples is merely a subset of the functionality of lists), etc.

What about the internals of Ruby bother you?

Python is making leaps and bounds while Ruby stands still

This simply isn't true. The fact that there are ~5 Ruby books in the process of being published (there were 0 in 2000) is only the most obvious evidence that there are LOTS of people interested in Ruby. Has it hit critical mass yet, or does it have more users than Python? No -- but it's absurd to say it's "standing still". And of course, Perl has more users than both languages combined, and Java dwarfs all 3.

why Python is gaining things like coroutines and generators while Ruby isn't.

Perhaps because Ruby's design didn't suffer from as many problems as Python's does -- so there's no need to correct them! :) But seriously, generators/iterators are (IIRC) directly inspired by Ruby; I'm not sure how Python is implementing coroutines, but I would suspect the reason that no such radical changes are being proposed for Ruby is that they're no needed. There is an interpreter rewrite coming up (Ruby 2), but so far, the wishlist includes only a couple major things (native threads, bytecode compilation) -- most of the changes will just be minor, backwards-incompatible API changes to fix warts and the lile. It's not like there is a huge lack of manpower to implement major changes -- simply because they're not needed.

[Python's implementation is] more readable and more consistent, and by those attributes more accessible to people who want to hack on it.

I'd agree with you on this -- Ruby's implementation is mostly hacked on by 3 or 4 language gurus, that's it. Most major changes are implemented by matz (the language creator). However, this is entirely a function of maturity, as dockeen pointed out. Another goal of the upcoming rewrite is to improve the quality/clarity/readibility of the implementation so that future maintainence work is simplified.
 

dockeen

Ars Tribunus Militum
1,600
Another question, mostly in the nature of curiosity. I really only became aware of the existence of Ruby about 1 -2 years ago. Does this qualify me as cave dweller or John Q. Public? I know I knew of, and was using Python a year or two before that, and PERL several years before that.

A deep left field question. Not long after I first heard about Ruby, I read a blurb somewhere on Lua. Where does it fall with respect to Ruby, both as a language and as a mass of users, or lack thereof?

Wayne
 

_klamath_

Ars Scholae Palatinae
770
I read a blurb somewhere on Lua. Where does it fall with respect to Ruby, both as a language and as a mass of users, or lack thereof?

I've heard it referred to most charitably as an extension / scripting language for building larger systems (e.g. write a game, allow scripting via Lua instead of writing your own language). I've never investigated it, but IIRC, it is very minimalistic. That's the impression I got, though: I won't pretend to know anything about the language first-hand though.

Does this qualify me as cave dweller or John Q. Public?

You heard about it around the same time I did -- so I think about average, for an English-speaking guy. It was in use in Japan a while before that (it's more popular than Python there), but it was only until the first English-language Ruby book was published that Ruby really started to get some attention.
 
D

Deleted member 5324

Guest
Originally posted by _klamath_:
What parts of Ruby "under the covers" have this look and feel that you refer to?

All of it. The code's there, and free -- read it yourself if you're really
curious. Ruby's implementation looks a lot more like something I'd write
than like something a good programmer would write. Compared to Python, the C
code that implements Ruby looks more...juvenile.

You mention later in your post that Ruby is up for a major rewrite. One of the
main reasons you list for such a rewrite is to improve the
"quality/clarity/readability" of Ruby's implementation. If even the developers
of Ruby admit it's implemented rather...grotily (that's the adverb form of
"grote" pronounced "grow-tee") then I don't think much more evidence is needed.

For instance, the silly type/class distinction,

Which, um, doesn't exist anymore since 2.2.

the need to pass 'self' to every object method explicitely,

Rather than having an extra syntactical construct for referencing member
variables, like Ruby does? I'll take Python's way any day.

the naming of lots of functions prefixed with '__' (rather than, say, access control),

Access control really plays no part in the decision to make standard
implementation functions be prefixed and afixed with a double underscore.

Do you suggest not reserving names for the implementation?

How do you suggest allowing classes to override operators without introducing
extra syntax for it?

the mediocre C API,

In what ways? At the very least it's far more consistent than Ruby's C API --
Ruby's api has a number of (in my opinion) awkwardly named functions, some of
which have no prefix, some of which have a "ruby_" prefix, some of which have an
"rb_" prefix. Such a diversely named API really doesn't lend a feeling of
maturity to the language.

the duplicity of having both lists and tuples (when the functionality of tuples is merely a subset of the functionality of lists), etc.

Tuples are immutable. Lists are mutable. Aside from the several obvious
optimizations that are possible with tuples that aren't possible with lists, it
additionally allows a unified interface for tuple decomposition and, say, function
argument access.

What about the internals of Ruby bother you?

Just as one example -- Ruby doesn't compile to bytecode. It recursively walks
the Abstract Syntax Tree. This not only requires (a) recursion*, but also
requires that the program be lexed, parsed, and optimized every time it's
run
. Python, on the other hand, compiles to bytecode and caches the
compilation result, thus reducing startup time for large programs.

That's just one example.

* No, I don't mind recursion, but it's certainly less than optimal in a language
like C. It also introduces a needless dependency of Ruby programs on the C
stack (which, admittedly, Python still has in most implementations (not in
stackless, though :)) but is still annoying, even in Python.)

This simply isn't true. The fact that there are ~5 Ruby books in the process of being published (there were 0 in 2000) is only the most obvious evidence that there are LOTS of people interested in Ruby. Has it hit critical mass yet, or does it have more users than Python? No -- but it's absurd to say it's "standing still". And of course, Perl has more users than both languages combined, and Java dwarfs all 3.

I'm not talking about the number of books a language has (and worry not, Python
has far more than just 5 in the process of being published, and far more already
on the shelves :)). I'm talking about technological innovation in the
implementation. Python has been modified to run on Palm Pilots, it's been ported
to Java, there's an implementation available which has first class heap allocated
continuations, and the language itself has just gotten generators (and with them
coroutines) and iterators. Python the language and Python the implementations
have been making significant technological progress.

Where's Ruby while all this is happening?

Perhaps because Ruby's design didn't suffer from as many problems as Python's does -- so there's no need to correct them! :)

Ha! Good thing that's a joke... :)

But seriously, generators/iterators are (IIRC) directly inspired by Ruby;

No, they're not. Neither the PEP for generators nor the one for iterators says
a thing about Ruby. That makes sense because Ruby has nothing comparable
either to generators or to a generic iteration interface for all objects.

I'm not sure how Python is implementing coroutines, but I would suspect the reason that no such radical changes are being proposed for Ruby is that they're no needed.

There's nothing bad about generators or a generic iteration API for objects.
These are things that unequivocally aid in programming. Obviously
languages can succeed without them (cf. Python before 2.2), but if such
things can be implemented, they should. Ruby in all likelihood doesn't have
them because (a) Matz doesn't feel like implementing them, (b) Matz doesn't
think they're worth implementing, and/or (c) No one else in the Ruby world has
the capability or the drive to implement them himself. It's probably all three
-- and (c), IMO, isn't due only to the small size of the Ruby world -- I think
it's also very much due to the lower quality implementation of Ruby.

There is an interpreter rewrite coming up (Ruby 2), but so far, the wishlist includes only a couple major things (native threads, bytecode compilation) -- most of the changes will just be minor, backwards-incompatible API changes to fix warts and the lile. It's not like there is a huge lack of manpower to implement major changes -- simply because they're not needed.

I honestly do think it's a significant lack of manpower to implement
major changes.

I'd agree with you on this -- Ruby's implementation is mostly hacked on by 3 or 4 language gurus, that's it. Most major changes are implemented by matz (the language creator). However, this is entirely a function of maturity, as dockeen pointed out. Another goal of the upcoming rewrite is to improve the quality/clarity/readibility of the implementation so that future maintainence work is simplified.

No, it's not entirely a function of maturity. Some people consistently write
better (more readable, more efficient, whatever metric you choose to use in
varying degrees) code than others. From all appearences, the people who have
been coding on Python have simply been writing better code than those that have
been coding on Ruby. If nothing else, they've written cleaner, more readable
code.

Ruby began being coded in 1993. Python began being coded in 1990. If it was
simply a matter of maturity, Ruby should be as cleanly and readably implemented
now as Python was in 1999. But it's not -- download the source code to Python
1.5.2 (released in April 1999) and compare. Python, even back then, was still
more cleanly and readably implemented than Ruby is now. Go back even further if
you like. You'll find that Python, even in its far less mature stages, was
written more cleanly and readably than Ruby is now.

Jeremy
 
D

Deleted member 5324

Guest
Originally posted by dockeen:
A deep left field question. Not long after I first heard about Ruby, I read a blurb somewhere on Lua. Where does it fall with respect to Ruby, both as a language and as a mass of users, or lack thereof?

It's a very small language, both in implementation size (it's less than
10k LoC in C), library size (miniscule) and userbase.

It's written cleanly and understandably, but its C API, from what I've seen,
leaves something to be desired -- it's not as high-level as Ruby or Python's API
is.

Jeremy
 

_klamath_

Ars Scholae Palatinae
770
First off, I think this is getting a bit ridiculous. Compared to other languages, Ruby and Python are very similar; I'd much rather be coding that Python than almost any other language, excluding Ruby. That said, I prefer Ruby (as you prefer Python). So if there is anything wrong with Python (or Ruby), it's not going to be on an issue of immense importance: I think both languages get most of the key elements of language design right.

You mention later in your post that Ruby is up for a major rewrite. One of the main reasons you list for such a rewrite is to improve the "quality/clarity/readability" of Ruby's implementation.

Yes, I'll admit that the general impression is that the current Ruby implementation is a bit inaccessible to most Ruby programmers. It's implemented almost entirely in C (whereas some people are talking about a Ruby-in-Ruby design), and as I said before, is mainly hacked on by matz. I'm not too worried about this though, because there really aren't many issues with the interpreter proper. I really can't think of a major language feature or syntactic sugar I'd like to see in Ruby -- what is really needed is more applications, libraries and documentation.

Which, um, doesn't exist anymore since 2.2.

My bad -- my info on Python is a bit out of date. But this is an example of what I was referring to: this problem didn't need fixing in Ruby.

Rather than having an extra syntactical construct for referencing member variables, like Ruby does? I'll take Python's way any day.

What's wrong with more syntax? The goal of a language's syntax is to communicate information. Rather than forcing the programmer to laboriously type in verbose syntactic cruft to work around a language limitation, I'd much rather use a simple prefix of '@'. This makes the intent much more clear, and helps the programmer to easily distinguish between member variables and lexical ones.

How do you suggest allowing classes to override operators without introducing extra syntax for it?

First, I'm quite skeptical about operator overloading. But in Ruby, it is implemented without requiring extra syntax: for instance, you can define the '[]' method on an object/class. That means that this code will work:

code:<HR>
Code:
anObj['foo']

Similarly, defining '[]=' will allow assignments as above to work.

In what ways? At the very least it's far more consistent than Ruby's C API -- Ruby's api has a number of (in my opinion) awkwardly named functions, some of which have no prefix, some of which have a "ruby_" prefix, some of which have an "rb_" prefix. Such a diversely named API really doesn't lend a feeling of maturity to the language.

All the commonly used Ruby API functions begin with "rb_". Again, you seem to emphasize naming and fairly superficial aesthetic concerns over functionality. As for the API itself, the main thing that iritates me about Python's C API is the need to do manual reference counting. Beyond that I haven't looked at it closely enough to be able to comment.

Tuples are immutable. Lists are mutable. Aside from the several obvious optimizations that are possible with tuples that aren't possible with lists, it additionally allows a unified interface for tuple decomposition and, say, function argument access.

What optimizations can be performed due to this distinction?

Can you explain what you mean by the end of the 2nd sentance?

In any case, it seems that the benefit of these 2 data types is clearly outweighed by natural drawbacks of introducing a new data type, with special syntax to learn (which is something Python programmers typically evangelize about).

Just as one example -- Ruby doesn't compile to bytecode.

I would think that the performance impact of this is basically negligable (parsing hardly requires a lot of CPU time). In any case, this is one of the issues that is going to be rectified in Ruby 2 (and/or the Ruby parrot stuff).

[Python]'s been ported to Java

As has Ruby.

(wow, long post jemfinch ;) I'll respond to the rest tomorrow)
 
D

Deleted member 5324

Guest
Originally posted by _klamath_:
Yes, I'll admit that the general impression is that the current Ruby implementation is a bit inaccessible to most Ruby programmers. It's implemented almost entirely in C (whereas some people are talking about a Ruby-in-Ruby design), and as I said before, is mainly hacked on by matz. I'm not too worried about this though, because there really aren't many issues with the interpreter proper. I really can't think of a major language feature or syntactic sugar I'd like to see in Ruby -- what is really needed is more applications, libraries and documentation.

I must not have emphasized what I was referring to there -- I'm talking
specifically (and only, in that situation :)) about Ruby's implementation in C.
It's much more inaccessible to more C coders than Pyhton's implementation
in C. That was my point.

My bad -- my info on Python is a bit out of date. But this is an example of what I was referring to: this problem didn't need fixing in Ruby.

That's true, but now it doesn't need fixed in Python, either :)

What's wrong with more syntax? The goal of a language's syntax is to communicate information. Rather than forcing the programmer to laboriously type in verbose syntactic cruft to work around a language limitation, I'd much rather use a simple prefix of '@'. This makes the intent much more clear, and helps the programmer to easily distinguish between member variables and lexical ones.

Every syntax rule is another rule that has to be taken into account when reading
a program. Fewer rules means less overhead in converting a program from ASCII
to patterns of synaptical bursts. Aside from that, I find the specific
reference to self much more "intuitive" than using a symbol that has no real
relation to "member variables."

First, I'm quite skeptical about operator overloading. But in Ruby, it is implemented without requiring extra syntax: for instance, you can define the '[]' method on an object/class. That means that this code will work:

Quote: "
anObj['foo']
"

Similarly, defining '[]=' will allow assignments as above to work.

Ah, yes, Ruby does restrict identifiers less than Python. The cost, however, is
a greater restriction on the use of operators (as in, they require
whitespace...not a huge deal, just noting its existence.)

All the commonly used Ruby API functions begin with "rb_". Again, you seem to emphasize naming and fairly superficial aesthetic concerns over functionality. As for the API itself, the main thing that iritates me about Python's C API is the need to do manual reference counting. Beyond that I haven't looked at it closely enough to be able to comment.

Python's C API is different than Ruby's. I don't know which is superior
(though I'll admit Ruby's is superior in not requiring reference counting) but
from examining both, you'll find Python's more consistent and "mature looking,"
I think.

"Superficial aesthetic concerns" are really what the differences between Python
and Ruby mostly boil down to. While each concern might be superficial in and of
itself, the total significance of the differences is much greater when these
concerns are combined.

Quote: "Tuples are immutable. Lists are mutable. Aside from the several obvious optimizations that are possible with tuples that aren't possible with lists, it additionally allows a unified interface for tuple decomposition and, say, function argument access.
"

What optimizations can be performed due to this distinction?

Well, the wide array of optimizations that can be performed with immutable data
structures that can't be performed with mutable ones.

You don't have to lock tuples. You can pass them to clients without worrying
that they might modify them. You can implement them more simply and efficiently
than lists.

Can you explain what you mean by the end of the 2nd sentance?

C functions that interface with Python simply take a tuple of the arguments
given to the function. Python provides useful facilities for decomposing tuples
(and thus, function arguments) into their consituent objects.

In any case, it seems that the benefit of these 2 data types is clearly outweighed by natural drawbacks of introducing a new data type, with special syntax to learn (which is something Python programmers typically evangelize about).

I don't think there's a significant cost. I prefer having them to not having
them.

Quote: "Just as one example -- Ruby doesn't compile to bytecode."

I would think that the performance impact of this is basically negligable (parsing hardly requires a lot of CPU time).

No, in comparison to evaluating, it doesn't -- but Python has projects as large
as 140,000 lines of Python code. Such projects would take significantly longer
to restart if Python didn't cache bytecode. Additionally, the compiled bytecode
can be optimized, and that optimization is useful every time the bytecode is.

Gosh, I thought I knew more reasons why bytecode is supposed to be faster than
evaluating an abstract syntax tree, but I can't remember them now.

In any case, this is one of the issues that is going to be rectified in Ruby 2 (and/or the Ruby parrot stuff).

But, of course, Python won't be standing still during the time Ruby is resolving
this issue. By the time Ruby compiles to bytecode, it's likely that Python will
have leapt forward by a whole new set of capabilities :)

Jeremy
 

dockeen

Ars Tribunus Militum
1,600
I am in the process of reading the on-line version of the
"Programming Ruby" book. It is a pleasant break from
the work of finishing up my SPIE paper and helping someone
finish a paper that was also nice enough to put my name
on. (You know, the stuff I am supposed to be doing)

Gotta get published to enable going back to academia as
an alternative when I get fired for know too many
computer languages too badly. :)

Wayne
 

sittidae

Ars Centurion
325
Subscriptor
But, of course, Python won't be standing still during the time Ruby is resolving this issue. By the time Ruby compiles to bytecode, it's likely that Python will have leapt forward by a whole new set of capabilities

That's the whole point of having a diversity of scripting languages. Each one borrows ideas from each other and then adds a new twist. After each release, the process starts over again.
 
Status
Not open for further replies.