SQLite

Anyone working on a Ruby interface for SQLite?

http://www.sqlite.org/

Bob X wrote:

Anyone working on a Ruby interface for SQLite?

http://www.sqlite.org/

I was curious, so I clicked around on that site a bit and got to…

http://domingo.dad-it.com/ruby-sqlite.whtm

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.10.22 at 23.26.10

···

On Wed, 23 Oct 2002 10:38:31 +0900, Bob X wrote:

Anyone working on a Ruby interface for SQLite?
http://www.sqlite.org/

From http://cvs.hwaci.com:2080/sqlite/wiki?p=SqliteWrappers

Here’s a SRPM package which I made from the source files at
http://domingo.dad-it.com/ruby-sqlite.whtm.

To compile just do a:
rpm --rebuild ruby-sqlite-0.1-1.src.rpm

Bob X wrote:

ruby-sqlite-0.1-1.src.rpm (4.26 KB)

···

Anyone working on a Ruby interface for SQLite?

http://www.sqlite.org/


Wai-Sun “Squidster” Chia
Consulting & Integration
Linux/Unix/Web Developer Dude

That’s correct. Ruby/DBI supports it, but it has not been tested enough.

Regards,

Michael

···

On Wed, 2002-10-23 at 05:37, Austin Ziegler wrote:

On Wed, 23 Oct 2002 10:38:31 +0900, Bob X wrote:

Anyone working on a Ruby interface for SQLite?
http://www.sqlite.org/

From http://cvs.hwaci.com:2080/sqlite/wiki?p=SqliteWrappers

In article 1035364235.286.92.camel@michael.neumann.all,

That’s correct. Ruby/DBI supports it, but it has not been tested enough.

Speaking of Ruby/DBI, is there any plan to support a host specification
within the connection string w/o needing to use dbd_proxy and running
another process ?

Perl/DBI does support it.

e.g.

dbh = DBI.connect (“dbi:Pg:#{spamdb}:host=#{host}”, “roberto”, “”,
‘AutoCommit’ => false)

Thanks,

···

Michael Neumann 520079130762-0001@t-online.de wrote:

Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- roberto@eurocontrol.fr
Usenet Canal Historique FreeBSD: The Power to Serve!

dbh = DBI.connect ("dbi:Pg:#{spamdb}:host=#{host}", "roberto", "",
                   'AutoCommit' => false)

Well, it exist no ?

···

##
  # parse a string of the form "database=xxx;key=val;..."
  # or database:host and return hash of key/value pairs
  #
  # improved by John Gorman <jgorman@webbysoft.com>
  def Utils.parse_params(str)
    params = str.split(";")
    hash = {}
    params.each do |param|
      key, val = param.split("=")
      hash[key] = val if key and val
    end
    if hash.empty?
      database, host = str.split(":")
      hash['database'] = database if database
      hash['host'] = host if host
    end
    hash
  end

Guy Decoux

This is supported in Ruby/DBI, too.
But if a host-specifier is allowed or not strongly depends on the used
database, whether or not the database accepts connections over the
network.

The driver-URL format is very close to that of Perl’s DBI.

Regards,

Michael

···

On Mon, 2002-10-28 at 13:09, Ollivier Robert wrote:

In article 1035364235.286.92.camel@michael.neumann.all,
Michael Neumann 520079130762-0001@t-online.de wrote:

That’s correct. Ruby/DBI supports it, but it has not been tested enough.

Speaking of Ruby/DBI, is there any plan to support a host specification
within the connection string w/o needing to use dbd_proxy and running
another process ?

Perl/DBI does support it.

e.g.

dbh = DBI.connect (“dbi:Pg:#{spamdb}:host=#{host}”, “roberto”, “”,
‘AutoCommit’ => false)

Hi all,

I’m a Ruby newbie, and I’m reading now “the ruby way” and reading this
book some comments make me think.
I’ve a strong Smalltalk heritage, so I’m somewhat biassed.

I would like to know…

Why does common operators like “=” , “and”, " …" , “or” etc … can
not be overloaded or redefined ?, maybe the complexity of the Ruby
parser comes from the fact that everything is ALMOST an object or a
method. Why is not “=” a method ? Same question for “and” and the rest
of operators that can not be redefined, Does the actual implementation
make life easier for the designer ? I say so because for me is more
natural when everything is an object (without exceptions, here Ruby
follows the rule pretty well) and a method is a method ever, not
sometimes. Some methods are keywords, and some other are not v.g. loop
vs. while. The every call is a method could simplify greatly the sintax
parser (look at the Smalltalk parser).

Why primitives are hidden ? In smalltalk you can call a primitive every
time you want with a <primitive: aNumber> , this way the implementation
of native methods, and in some way native Classes like String are not
hidden from the programmer, freeing the programmer to change the
behaviour if needed. Yes you can have the “required” clause and use
binary libraries, but would not be much more “natural” to have a
"require string" when you want to invoque string libraries instead of
having them loaded all the time ?. I want to say here that the
"primitive" keyword frees the language from it’s implementation. This
favours the everything is a module aproach.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things are
orthogonal with the principe that must drive it, you can wite a.+(3) or
a + 3 or a.+ 3 or a hundred other ways to write the same thing, yes,
this gives you freedom, but a bad deserved (not needed) one. I use one
form, but when I read programs from other persons the code seems strange
and somewhat dificult to read. Sometimes SS is right, v.g. x +=1, but
the every call is a method aproach could give you the same results
without trouble, in this case += could be a method. As could be “++” or
others.

Undeclared variables, I don’t know other people but I do fast typing and
writing “aVariable” and “aVariabel” is a mistake that I can do very
easily. Yes you can say, type more slowly, but this is not a solution, I
would like to have a way to force the compiler to generate a warning
when I use a non pre-declared (or pre asigned) variable.

Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of double chars i.e. integer), I don’t know
you, but for me aString[i].chr ==‘x’ is somewhat unnatural, because it
breaks the semantic of a String, so it’s not intuitive for me.

Why is Ruby an interpreter ? Yes the less traditional bytecode aproach,
can be harder (or not), but enables external optimizations more easily
(JIT and similars) because the language are separated from the
implementation, enables reduced footprint and gives faster execution
times, yes, look at how Self executes programs, it’s amazingly fast (and
incredibly complex also), but a separated implementation could help
develop better Ruby-engines.

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing, and I love how easy is to learn, it’s dinamicity
and the fact that is a kind of mix between my loved Smalltalk, Self and
other languages. In fact I’m writing this because I want to understand
Ruby better and becasue I want to make some suggestions for future
releases, maybe Mr. Matsumoto would like to consider some of them

There are more things that I see as strange in Ruby, but this is enought
for now …

Please if I’ve make any inaccuracy , don’t be too rude with me, I’m
still learning, and I’ve a loooong way before understand everyting. I’m
just looking for answers.

Enric

Hi all,

I’m a Ruby newbie, and I’m reading now “the ruby way” and reading this
book some comments made me think a lot about Ruby.
I’ve a strong Smalltalk heritage, so I’m somewhat biassed.

I would like to know…

Why does common operators like “=” , “and”, " …" , “or” etc … can
not be overloaded or redefined ?, maybe the complexity of the Ruby
parser comes from the fact that everything is ALMOST an object or a
method. Why is not “=” a method ? Same question for “and” and the rest
of operators that can not be redefined, Does the actual implementation
make life easier for the designer ? I say so because for me is more
natural when everything is an object (without exceptions, here Ruby
follows the rule pretty well) and a method is a method ever, not
sometimes. Some methods are keywords, and some other are not v.g. loop
vs. while. The every call is a method could simplify greatly the sintax
parser.

Why primitives are hidden ? In smalltalk you can call a primitive every
time you want with a <primitive: aNumber> , this way the implementation
of native methods, and in some way native Classes like String are not
hidden from the programmer, freeing the programmer to change the
behaviour if needed. Yes you can have the “required” clause and use
binary libraries, but would not be much more “natural” to have a
"require string" when you want to invoque string libraries instead of
having them loaded all the time ?. I want to say here that the
"primitive" keyword frees the language from it’s implementation. This
favours a everything is a module aproach.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things are
orthogonal with the principe that must drive it, you can wite a.+(3) or
a + 3 or a.+ 3 or a hundred other ways to write the same thing, yes,
this gives you freedom, but a bad deserved (not needed) one. I use one
form, but when I read programs from other persons the code seems strange
and somewhat dificult to read. Sometimes SS is right, v.g. x +=1, but
the every call is a method aproach could give you the same results
without trouble, in this case += could be a method. As could be “++” or
others.

Undeclared variables, I don’t know other people but I do fast typing and
writing “aVariable” and “aVariabel” is a mistake that I can do very
easily. Yes you can say, type more slowly, but this is not a solution, I
would like to have a way to force the compiler to generate a warning
when I use a non pre-declared (or pre asigned) variable.

Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of double chars i.e. integer), I don’t know
you, but for me aString[i].chr ==‘x’ is somewhat unnatural, because it
breaks the semantic of a String, so it’s not intuitive for me.

Why is Ruby an interpreter ? Yes the less traditional bytecode aproach,
can be harder (or not), but enables external optimizations more easily
(JIT and similars) because the language are separated from the
implementation, enables reduced footprint and gives faster execution
times, yes, look at how Self executes programs, it’s amazingly fast (and
incredibly complex also), but a separated implementation could help
develop better Ruby-engines.

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing, and I love how easy is to learn, it’s dinamicity ,
it’s scriptability and the fact that is a kind of mix between my loved
Smalltalk, Self and other languages. In fact I’m writing this because I
want to understand Ruby better and becasue I want to make some
suggestions for future releases, maybe Mr. Matsumoto would like to
consider some of them.

There are more things that I see equally strange in Ruby, but this is
enought for now …

Please if I’ve make any inaccuracy , don’t be too rude with me, I’m
still learning, and I’ve a loooong way before I understand everyting.
I’m just looking for answers and explanations.

Enric

Hi all,

I’m a Ruby newbie, and I’m reading now “the ruby way” and reading this
book some comments made me think a lot about Ruby.
I’ve a strong Smalltalk heritage, so I’m somewhat biassed.

I would like to know…

Why does common operators like “=” , “and”, " …" , “or” etc … can
not be overloaded or redefined ?, maybe the complexity of the Ruby
parser comes from the fact that everything is ALMOST an object or a
method. Why is not “=” a method ? Same question for “and” and the rest
of operators that can not be redefined, Does the actual implementation
make life easier for the designer ? I say so because for me is more
natural when everything is an object (without exceptions, here Ruby
follows the rule pretty well) and a method is a method ever, not
sometimes. Some methods are keywords, and some other are not v.g. loop
vs. while. The every call is a method could simplify greatly the sintax
parser.

Why primitives are hidden ? In smalltalk you can call a primitive every
time you want with a <primitive: aNumber> , this way the implementation
of native methods, and in some way native Classes like String are not
hidden from the programmer, freeing the programmer to change the
behaviour if needed. Yes you can have the “required” clause and use
binary libraries, but would not be much more “natural” to have a
"require string" when you want to invoque string libraries instead of
having them loaded all the time ?. I want to say here that the
"primitive" keyword frees the language from it’s implementation. This
favours a everything is a module aproach.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things are
orthogonal with the principe that must drive it, you can wite a.+(3) or
a + 3 or a.+ 3 or a hundred other ways to write the same thing, yes,
this gives you freedom, but a bad deserved (not needed) one. I use one
form, but when I read programs from other persons the code seems strange
and somewhat dificult to read. Sometimes SS is right, v.g. x +=1, but
the every call is a method aproach could give you the same results
without trouble, in this case += could be a method. As could be “++” or
others.

Undeclared variables, I don’t know other people but I do fast typing and
writing “aVariable” and “aVariabel” is a mistake that I can do very
easily. Yes you can say, type more slowly, but this is not a solution, I
would like to have a way to force the compiler to generate a warning
when I use a non pre-declared (or previously asigned) variable.

Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of 16bit chars, a.k.a. short integer). I
don’t know for you, but for me aString[i].chr ==‘x’ is somewhat
unnatural, because it breaks the semantic of a String, so it’s not
intuitive for me.

Why is Ruby an interpreter ? Yes the less traditional bytecode aproach,
can be harder (or not), but enables external optimizations more easily
(JIT and similars) because the language are separated from the
implementation, enables reduced footprint and gives faster execution
times, yes, look at how Self executes programs, it’s amazingly fast (and
complex also), but a separated implementation could help develop better
Ruby-engines.

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing, and I love how easy is to learn, it’s dinamicity ,
it’s scriptability and the fact that is a kind of mix between my loved
Smalltalk, Self and other languages. In fact I’m writing this because I
want to understand Ruby better and becasue I want to make some
suggestions for future releases, maybe Mr. Matsumoto would like to
consider some of them.

There are more things that I see equally strange in Ruby, but this is
enought for now …

Please if I’ve make any inaccuracy , don’t be too rude with me, I’m
still learning, and I’ve a loooong way before I understand everyting.
I’m just looking for answers and explanations.

Enric

In article 1035808517.286.9.camel@michael.neumann.all,

···

Michael Neumann 520079130762-0001@t-online.de wrote:

This is supported in Ruby/DBI, too.
But if a host-specifier is allowed or not strongly depends on the used
database, whether or not the database accepts connections over the
network.

Thanks, last time I checked, it wasn’t here (or I missed it).

Duh.

Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- roberto@eurocontrol.fr
Usenet Canal Historique FreeBSD: The Power to Serve!

Hi all,

Hi Enric…

The list is quiet since many of the main posters
are at the Ruby Conference in Seattle. :slight_smile: I’ll try
to answer what I can here.

I also suggest that you read the Ruby FAQ (which is
on rubycentral.com I think).

I’m a Ruby newbie, and I’m reading now “the ruby way” and reading this
book some comments make me think.
I’ve a strong Smalltalk heritage, so I’m somewhat biassed.

Thank you for reading it. I hope still more people will.

I don’t know Smalltalk, though I’ve heard great things about it,
so I can’t comment on that specifically.

I would like to know…

Why does common operators like “=” , “and”, " …" , “or” etc … can
not be overloaded or redefined ?, maybe the complexity of the Ruby
parser comes from the fact that everything is ALMOST an object or a
method. Why is not “=” a method ?

Here is one way to look at it. A variable is essentially a reference
to an object. A method is invoked on an object. An object never
changes class (perhaps it can in Smalltalk?).

If I say: x = “hello”
then what is the receiver for the method call “=”? You can’t say it’s
x, because x is not an object.

On the other hand, the number 5 is an object. If I say: 5 = “hello”
does that mean that every reference to the number 4 is now a reference
to the string “hello”?

Same question for “and” and the rest
of operators that can not be redefined, Does the actual implementation
make life easier for the designer ? I say so because for me is more
natural when everything is an object (without exceptions, here Ruby
follows the rule pretty well) and a method is a method ever, not
sometimes. Some methods are keywords, and some other are not v.g. loop
vs. while. The every call is a method could simplify greatly the sintax
parser (look at the Smalltalk parser).

I can’t speak for Matz, but I have NEVER seen him make a design decision
because it made life easier for the designer rather than the programmer.

I have seen him make compromises for clarity or efficiency, however. I
suspect that these fall into these categories somewhere.

As for simplifying the parser: I think you will agree it is better to
have a readable, usable language than a simple parser.

Sometimes languages that are very powerful have difficult syntax (LISP,
Smalltalk, etc.). LISP is arguably the most powerful language in the
world, but people find it difficult to learn and use. Ruby is full of
compromises in its design.

Why primitives are hidden ? In smalltalk you can call a primitive every
time you want with a <primitive: aNumber> , this way the implementation
of native methods, and in some way native Classes like String are not
hidden from the programmer, freeing the programmer to change the
behaviour if needed. Yes you can have the “required” clause and use
binary libraries, but would not be much more “natural” to have a
“require string” when you want to invoque string libraries instead of
having them loaded all the time ?. I want to say here that the
“primitive” keyword frees the language from it’s implementation. This
favours the everything is a module aproach.

I’m not sure about everything you’re asking here. But you can in fact
change the behavior of the standard classes, since the classes are “open.”
There are many examples of this in TRW.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things are
orthogonal with the principe that must drive it, you can wite a.+(3) or
a + 3 or a.+ 3 or a hundred other ways to write the same thing, yes,
this gives you freedom, but a bad deserved (not needed) one. I use one
form, but when I read programs from other persons the code seems strange
and somewhat dificult to read. Sometimes SS is right, v.g. x +=1, but
the every call is a method aproach could give you the same results
without trouble, in this case += could be a method. As could be “++” or
others.

In Ruby, a += b means a = a + b ALWAYS, without fail. This means that you
get += “for free” when you define +, and you are spared having to write
both. If you want += to have some other meaning, I would have to ask “Why?”
It seems logical to me to tie the meaning of += to + (unlike C++).

As for ++ and --, these are impossible in Ruby for much the same reason
I mentioned before. They are operations on variables, whereas Ruby methods
and operators work on objects. If I say: x++ I am trying to increment
the OBJECT that x refers to. Does this mean that every variable with the
same value should be changed also? For that matter, what should 5++ mean?

Undeclared variables, I don’t know other people but I do fast typing and
writing “aVariable” and “aVariabel” is a mistake that I can do very
easily. Yes you can say, type more slowly, but this is not a solution, I
would like to have a way to force the compiler to generate a warning
when I use a non pre-declared (or pre asigned) variable.

If you use it on the right hand side, it will be an error.

It was difficult for me to get used to a language without variable
declarations. But it seems to be a thing which Matz always insists on.
And I got used to it, and now I like it.

Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of double chars i.e. integer), I don’t know
you, but for me aString[i].chr ==‘x’ is somewhat unnatural, because it
breaks the semantic of a String, so it’s not intuitive for me.

This was never intuitive for me either.

Why is Ruby an interpreter ? Yes the less traditional bytecode aproach,
can be harder (or not), but enables external optimizations more easily
(JIT and similars) because the language are separated from the
implementation, enables reduced footprint and gives faster execution
times, yes, look at how Self executes programs, it’s amazingly fast (and
incredibly complex also), but a separated implementation could help
develop better Ruby-engines.

This is planned. Matz wants to add bytecodes to 2.0 I think (which is
still vaporware). In addition, Parrot is being designed not just with
Perl in mind but Python and Ruby as well. So it should be possible to
write a Parrotized version as well (though it has not been done yet).

There is also JRuby, which strives for interoperation with Java. I have
not played with it yet.

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing, and I love how easy is to learn, it’s dinamicity
and the fact that is a kind of mix between my loved Smalltalk, Self and
other languages. In fact I’m writing this because I want to understand
Ruby better and becasue I want to make some suggestions for future
releases, maybe Mr. Matsumoto would like to consider some of them

My advice is to wait 90 days before suggesting language changes. :slight_smile:
Every newbie makes these suggestions (as I guess I did too). But most
of them have been thought of before (as a search of the list archives
will show). Some are under consideration, some are planned for the
future, and some have been rejected by Matz.

There are more things that I see as strange in Ruby, but this is enought
for now …

Please if I’ve make any inaccuracy , don’t be too rude with me, I’m
still learning, and I’ve a loooong way before understand everyting. I’m
just looking for answers.

I hope no one here is rude to you. If someone is, we will
come to your defense… :slight_smile:

Hal Fulton

···

----- Original Message -----
From: “Enric Lafont” enric@1smart.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, November 02, 2002 7:57 PM
Subject: Thoughts on Ruby

Hi all,

I’m a Ruby newbie, and I’m reading now “the ruby way” and reading this
book some comments make me think.
I’ve a strong Smalltalk heritage, so I’m somewhat biassed.

Hi, Enric.
I also have a Smalltalk background. When I first encountered Ruby I asked
myself many of the same questions you have.

I would like to know…

Why does common operators like “=” , “and”, " …" , “or” etc … can
not be overloaded or redefined ?, maybe the complexity of the Ruby
parser comes from the fact that everything is ALMOST an object or a
method. Why is not “=” a method ? Same question for “and” and the rest
of operators that can not be redefined, Does the actual implementation
make life easier for the designer ? I say so because for me is more
natural when everything is an object (without exceptions, here Ruby
follows the rule pretty well) and a method is a method ever, not
sometimes. Some methods are keywords, and some other are not v.g. loop
vs. while. The every call is a method could simplify greatly the sintax
parser (look at the Smalltalk parser).

Smalltalk is pure OOP. Ruby is not. In Smalltalk the “operators” are simply
messages to an object. In Ruby “operators” are neither objects nor messages,
but are rather handled as in more conventional languages. I don’t know why
Matz only went part way. This part-way-ness is also visible in other
aspects of the language such as “if”, “while”, etc. In Ruby these things
also are neither object nor message. Whereas in Smalltalk, such constructs
are messages to a Boolean object.

Why primitives are hidden ? In smalltalk you can call a primitive every
time you want with a <primitive: aNumber> , this way the implementation
of native methods, and in some way native Classes like String are not
hidden from the programmer, freeing the programmer to change the
behaviour if needed. Yes you can have the “required” clause and use
binary libraries, but would not be much more “natural” to have a
“require string” when you want to invoque string libraries instead of
having them loaded all the time ?. I want to say here that the
“primitive” keyword frees the language from it’s implementation. This
favours the everything is a module aproach.

Again, what can I say? Ruby is not Smalltalk. Large amounts of functionality
that in Smalltalk were written in Smalltalk, were in Ruby written in C.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things are
orthogonal with the principe that must drive it, you can wite a.+(3) or
a + 3 or a.+ 3 or a hundred other ways to write the same thing, yes,
this gives you freedom, but a bad deserved (not needed) one. I use one
form, but when I read programs from other persons the code seems strange
and somewhat dificult to read. Sometimes SS is right, v.g. x +=1, but
the every call is a method aproach could give you the same results
without trouble, in this case += could be a method. As could be “++” or
others.

I agree with you for the same reasons you give. I am a hater of syntax sugar.

Undeclared variables, I don’t know other people but I do fast typing and
writing “aVariable” and “aVariabel” is a mistake that I can do very
easily. Yes you can say, type more slowly, but this is not a solution, I
would like to have a way to force the compiler to generate a warning
when I use a non pre-declared (or pre asigned) variable.

This is a difference that I have grown to like. Running back to the top of a
method every I need a variable name was tedious.

Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of double chars i.e. integer), I don’t know
you, but for me aString[i].chr ==‘x’ is somewhat unnatural, because it
breaks the semantic of a String, so it’s not intuitive for me.

It is not intuitive to many people. There have been long discussions on the
pros and cons.

Why is Ruby an interpreter ? Yes the less traditional bytecode aproach,
can be harder (or not), but enables external optimizations more easily
(JIT and similars) because the language are separated from the
implementation, enables reduced footprint and gives faster execution
times, yes, look at how Self executes programs, it’s amazingly fast (and
incredibly complex also), but a separated implementation could help
develop better Ruby-engines.

All the things you mention are under consideration or under development.

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing, and I love how easy is to learn, it’s dinamicity
and the fact that is a kind of mix between my loved Smalltalk, Self and
other languages. In fact I’m writing this because I want to understand
Ruby better and becasue I want to make some suggestions for future
releases, maybe Mr. Matsumoto would like to consider some of them

Most of the features I loved about Smalltalk are in Ruby. But what I do not
miss from Smalltalk is fact that it is image based. Ruby is not, and I think
that is a good thing.

There are more things that I see as strange in Ruby, but this is enought
for now …

Please if I’ve make any inaccuracy , don’t be too rude with me, I’m
still learning, and I’ve a loooong way before understand everyting. I’m
just looking for answers.

I think you will find that this is a very friendly list. Welcome.

···

On Saturday 02 November 2002 7:57 pm, Enric Lafont wrote:

Enric


“I invented the term Object-Oriented, and I can
tell you I did not have C++ in mind.”
-Alan Kay

Why does common operators like “=” , “and”, " …" , “or” etc …
can not be overloaded or redefined ?, maybe the complexity of the
Ruby parser comes from the fact that everything is ALMOST an
object or a method.

I don’t actually see this (that everything is “almost” an object).
Personally, I think that matz has made the right choice in making
boolean operations (and, &&, or, ||) invariant in the language. You
can, by the way, redefine the bit operators (& and |). There’s
nothing worse than a language which doesn’t do what you expect it to
do with conditionals, and it does so on the whim of another
programmer.

Why is not “=” a method?

Because it’s not something done to objects, but to reference
variables that we use to manipulate objects. I’m really curious as
to why one would want to redefine assignment in the first place. I
mean, seriously. It’s not like this is C++ where you have to
reinvent everything every time you work with the bloody language.

Same question for “and” and the rest of operators that can not be
redefined, Does the actual implementation make life easier for the
designer ? I say so because for me is more natural when everything
is an object (without exceptions, here Ruby follows the rule
pretty well) and a method is a method ever, not sometimes.

This is just MNSHO, but again I don’t see why one would want to
allow such basic constructs to be redefined. IMO, you can redefine
everything except boolean tests and still have a useful – if obtuse
– language; if you try to redefine those, you’re not going to be
able to have any determinacy with the programs that are written.

Some methods are keywords, and some other are not v.g. loop vs.
while. The every call is a method could simplify greatly the
sintax parser (look at the Smalltalk parser).

while is a boolean test as much as a loop construct.

Why primitives are hidden ? In smalltalk you can call a primitive
every time you want with a <primitive: aNumber> , this way the
implementation of native methods, and in some way native Classes
like String are not hidden from the programmer, freeing the
programmer to change the behaviour if needed.

Why is it necessary to access the primitives? IMO, Java’s biggest
problem is that it makes the primitives available. In Ruby, by the
way, I can still change the behaviour of String – this is where
Ruby differs from every other language that I’ve ever used: it’s
dynamic. If I need a new function on String, I can add it whenever I
need. I’m looking at extending the functionality of a library that
I’ve ported so that it can optionally extend String and Array to
include this library as methods on String and Array instead of as
something else to operate on a String or an Array.

Yes you can have the “required” clause and use binary libraries,
but would not be much more “natural” to have a “require string”
when you want to invoque string libraries instead of having them
loaded all the time ?. I want to say here that the “primitive”
keyword frees the language from it’s implementation. This favours
the everything is a module aproach.

I disagree – allowing access to the primitives ties the developer
very tightly to the local implemententation of the language. I don’t
particularly care whether or not my integers are 32-bit or 64-bit or
even larger – I just expect them to do what they should do (and
that means possibly upclassing to a BigNum class if I exceed the
word size). I think that the only thing that I’d like to see in this
regard is for Ruby to take a page from Ada and allow me to define
ranges as types (that is, I want to be able to automatically define
a class UInt64 < Integer [(-264) … (264 - 1)] and have it do
the Right Thing).

It would NOT be much more natural to require every bloody module I
need every time I need it. A language – especially a language like
Ruby, where Strings are fundamental to everything – isn’t useful
without certain defaults. Would it not make equal sense to “require
integer” when I need to use integers, or are you suggesting that
those are fundamentals and are always included? Strings are part of
what makes Ruby useful immediately (the same applies to Files)
because it’s a scrpiting language.

Sintax Sugar (SS), other thing difficult to understand for me, the
question here is why ? Everything has exceptions very few things
are orthogonal with the principe that must drive it, you can wite
a.+(3) or a + 3 or a.+ 3 or a hundred other ways to write the same
thing, yes, this gives you freedom, but a bad deserved (not
needed) one. I use one form, but when I read programs from other
persons the code seems strange and somewhat dificult to read.

I’m sorry, but I don’t understand what you’re getting at here. The
three examples you gave:

a.+(3)
a.+ 3
a + 3

are actually the only ways to express that thought (without getting
silly wrt parenthesis). Ruby explicitly makes parentheses optional
on method calls. Parentheses make complex operations easier to read,
certainly, and can prevent confusion for the interpreter and
programmer, as when you have:

a b, c d
// Is this a(b, c(d)) – OR
// a(b), c(d)

This means only that “a + 3” is syntactic sugar for “a.+(3)” because
it is fundamentally more natural for most people to write “a + 3”
than either “a.+(3)” or even RPN “a 3 +”. Again, matz has made the
proper choice – it keeps the language easily accessible.

Sometimes SS is right, v.g. x +=1, but the every call is a method
aproach could give you the same results without trouble, in this
case += could be a method. As could be “++” or others.

Actually, it can’t give you the same results without trouble. C++
is trouble because it allows the definition of:

a = a + b // a.=(a.+(b))

to be different from:

a += b // a.+=(b)

If the result of the first call isn’t the same as the result of the
second call, then there’s a disconnect which has to be documented.
Matz made the right choice here, I think, because it prevents this
sort of stupidity that C++ allows. (And this isn’t ‘prevention’ in
the way that I think GvR was beyond silly to require indentation for
block definition in Python.)

Undeclared variables, I don’t know other people but I do fast
typing and writing “aVariable” and “aVariabel” is a mistake that I
can do very easily. Yes you can say, type more slowly, but this is
not a solution, I would like to have a way to force the compiler
to generate a warning when I use a non pre-declared (or pre
asigned) variable.

The interpreter will warn you of this, to some degree. If I try to
use an undefined variable, it will complain (at least with 1.7)
because the value is unknown (it’s not even properly ‘nil’). This
won’t help, however, if you have two similarly named variables.

Why are Strings arrays of integers ? aString[0] is an integer,
yes, it’s the way it is, but I would like to have String as an
array of chars, and char if you want as a descendant of Integer
(nice election because a Unicode String is and array of double
chars i.e. integer), I don’t know you, but for me aString[i].chr
==‘x’ is somewhat unnatural, because it breaks the semantic of a
String, so it’s not intuitive for me.

This one is easy: because it was a design decision made earlier. A
new version of String is being worked on, to the best of my
knowledge, that will deal with characters – but this leaves the
problem of existing code which will break because it uses the
current implementation.

Why is Ruby an interpreter ? Yes the less traditional bytecode
aproach, can be harder (or not), but enables external
optimizations more easily (JIT and similars) because the language
are separated from the implementation, enables reduced footprint
and gives faster execution times, yes, look at how Self executes
programs, it’s amazingly fast (and incredibly complex also), but a
separated implementation could help develop better Ruby-engines.

A bytecode system is being worked on, to the best of my knowledge.

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.11.03 at 00.12.35

···

On Sun, 3 Nov 2002 10:57:29 +0900, Enric Lafont wrote:

SORRY

I’ve sent the message TREE TIMES to the list.

But I’ve been receiving an error from the mailing list saying that the
message have not been processed, and worse of all, the message have been
hidden between other messages, so I can not see that the message has
been delivered.

I’m so sorry, please accept my apologices for the mistake.

Enric

When I started learning Ruby, some things didn’t feel natural (strings
as integer arrays for example), but I eventually learned to cope with
these and also, not think too much of the features I would like to have
(conses, tail-recursion optimization, etc.) Language designers do their
best to write a language that the actual community continues to like.
Larry Wall listens to the Perl people and if their suggestions make
sense, he probably adds them. Same goes for Guido Van Rossum and
Python. And matz listens to the Ruby community (he’s pretty active in
this ML).

Just give it time, eventually the large number of nice features in Ruby
will make it easier for you to accept the little annoyances.

Oh, welcome in the Ruby world!

Vince

···

Vincent Foley-Bourgon
Email: vinfoley@iquebec.com
Homepage: http://darkhost.mine.nu:81

Don’t get me wrong, I understand that Ruby is a young language that
needs some maturing,
[…]
I want to make some suggestions for future releases,
[…]
I’m still learning, and I’ve a loooong way before understand
everyting. I’m just looking for answers.

Are you trying to improve your understanding to fit Ruby or are you
trying to improve Ruby to fit your understanding?

Beware, because it really looks like the latter, in spite of the
closing sentence: you’re asking people not to be rude to you, yet
you’re being rude by throwing judgement at what you admittedly aren’t
familiar with.

Everyone here knows that it’s done in good faith and nobody will flame
you; thankfully Ruby has got a nice community and anyway most of us
wondered the same things once. I suggest you look through the
archives, because the answers to your questions are all there, and
follow Hal’s `ninety days’ advice. That way, people won’t get annoyed
and think ``here’s another newcomer knowing nothing about Ruby and
presuming he can improve it’'. Ok?

/me turns 180 degrees and speaks to the rest of ruby-talk:

Folks, what do you do when you see code like this?

c1 = 3 * 3 * Math::PI

c2 = 6 * 6 * Math::PI

c3 = 21 * 21 * Math::PI

You refactor, right?

def area(r)
  return r * r * Math::PI
end

c1 = area(3)
c2 = area(6)
c3 = area(21)

So we’ve got wisdom in programming. Can we please apply it
in life, too?

It’s simply too much to leave the list for a couple of days and find
half a hundred messages resurrecting topics (and beating them to death
again) such as:

- Alternatives in syntax or `There is more than one way to write
  it'
- Overloading '='
- Declaring variables
- Compiling Ruby to bytecode or whatever

First it was because Ruby is different than Pythong, then because it
is different than C++, now because it is different than Smalltalk,
tomorrow because it is different than God knows what.

Can we (or at least those who still have energy to answer, and yes I’m
cowardly leaving myself out) refactor this recurring `human code’ into
a wiki or whatever, and redirect people there? We don’t want
ruby-talk to become ruby-design-advocacy, right? And we don’t want
matz to waste his time justifying design decisions (which thankfully
he does very seldom already)?

William’s List of things that newcomer to Ruby should know'' does a great job of satisfying the practical concerns (How does it work
like…?‘’). Something is needed for the philosophical/theoretical
side (``Why is it like…?‘’).

Does this make sense?

Massimiliano

···

On Sun, Nov 03, 2002 at 10:57:29AM +0900, Enric Lafont wrote:

Albert Wagner wrote:

Smalltalk is pure OOP. Ruby is not. In Smalltalk the “operators” are simply
messages to an object. In Ruby “operators” are neither objects nor messages,
but are rather handled as in more conventional languages. I don’t know why
Matz only went part way. This part-way-ness is also visible in other
aspects of the language such as “if”, “while”, etc. In Ruby these things
also are neither object nor message. Whereas in Smalltalk, such constructs
are messages to a Boolean object.

If Ruby went all the way on this, like Smalltalk does, then Ruby would
almost be Smalltalk.
The unique about Ruby is that it combines the OO-ness of Smalltalk with
a more conventional syntax. I love Smalltalk’s syntax, but it did scare
a lot of people away.

(It can be argued that you could do “if” as messages internally, which
is left as an excercise to the reader :slight_smile:

/Anders

···

A n d e r s B e n g t s s o n | ndrsbngtssn@yahoo.se
Stockholm, Sweden |


Gratis e-mail resten av livet på www.yahoo.se/mail
Busenkelt!

[Enric:]
Why are Strings arrays of integers ? aString[0] is an integer, yes, it’s
the way it is, but I would like to have String as an array of chars, and
char if you want as a descendant of Integer (nice election because a
Unicode String is and array of double chars i.e. integer), I don’t know
you, but for me aString[i].chr ==‘x’ is somewhat unnatural, because it
breaks the semantic of a String, so it’s not intuitive for me.

It is not intuitive to many people. There have been long discussions on the
pros and cons.

It’s probably not intuitive to anybody (except perhaps Matz). However, I see
no particular justification for it being any other way, and in fact it’s
changing in 1.7 isn’t it? Anyway, my point is: you’ll never forget it now.
And if you’re like me, you won’t care either.

But to nitpick, a String is not an array of integers. It is a String :slight_smile:

Other options, if you’re testing equality of an individual character:

string[i] == ?x
string[i,1] == “x”

Cheers,
Gavin

···

From: “Albert Wagner” alwagner@tcac.net