What do you think about Ruby ?

Brian Mitchell binary42 at gmail.com
Sun Aug 7 17:20:37 UTC 2005


On 8/7/05, Blake <blake at kingdomrpg.com> wrote:
> On Sun, 07 Aug 2005 06:31:01 -0700, Jim Menard <jimm at io.com> wrote:
> 
> >> syntax. In other  words, the "foreign" construct of:
> >>  1 to: 4 do: [:i | Transcript show:i].
> >>  in Smalltalk is replcaed by:
> >>  i = 0
> >> begin
> >>   puts "#{i}"
> >>   i += 1
> >> end until i > 4
> >
> > What? In Ruby, I'd write either
> >
> >    4.times { | i | puts(i+i) }
> >
> > or perhaps, using the Range class,
> >
> >    (1..4).each { | i | puts i }
> 
> Probably because you're a Smalltalker, too.<s> Or perhaps Ruby is becoming
> more like Smalltalk. But I distinctly recall reading Ruby's creator(s?)
> discussing this. It's in their book (available online at ruby-lang.org):
> 
> "Take a true object-oriented language, such as Smalltalk. Drop the
> unfamiliar syntax and move to more conventional, file-based source code.
> Now add in a good measure of the flexibility and convenience of languages
> such as Python and Perl."
> 

I would and have been using the above mentioned style. One could also use:

1.upto(4) {|x| puts x} # a little closer to your original example.
# Note that the 4.times counts from 0 to 3.
# All of these examples could be written in pure Ruby but are in C for
the speed boost.

You will find a lot of familiar stuff in Ruby (inject is one of my favorites).

In the end I ought to mention I learned Smalltalk after Ruby because
of Ruby. Ruby is well designed (a message that some of you need to
take in -- whether or not it fits in where you do your work).
Smalltalk is wonderful. It has inspired many generations of languages
and it will continue to be a very potent paradigm, tool, or whatever
else you would like to classify it as.

Avoiding the classification of Smalltalk as a language may make sense
but I fear this is more in avoidance of comparison. Smalltalk can be
used in a language fashion, so why pretend that it is not.

> > Less so every major release.
> 
> Well, while I like Perl, I really wouldn't want to see it infect a bunch
> of other languages.<s>
> 

I'm no fan of Perl in any way. Perl did influence Ruby at the start
(we all have to start somewhere). On the other hand, Ruby, just like
Smalltalk, has matured to the point where it has its own idioms. This
is a key to why using Ruby is not necessarily related to Perl.

> > Yes, Ruby isn't image based. That's one reason I like it: I can use
> > Emacs.
> 
> I have very mixed feelings about the whole file/image thing. I think what
> I'd like to see is a more transparent image. So that I could write an
> object--I wouldn't use Emacs (or vi, don't shoot me)--but I would like to
> have all the source stored traditionally in files, with images being
> created from those, and you could move back and forth between them easily.
> 

I have to vote that having files speeds my development up in general
because of the way Ruby was designed to be used. Smalltalk works
naturally in an image. I fire up Squeak all the time to get new ideas
or prototype.

Brian.



More information about the Squeak-dev mailing list