Whither SmallScript? (was Re: Integer micro-benchmarks)

Andrew Hunt andy at toolshed.com
Fri Apr 27 13:27:07 EDT 2001


On Fri, 27 Apr 2001 16:33:05 GMT, Steve  Holden <sholden at holdenweb.com> wrote:
> 
> Personally I found it quite interesting that SmallTalkers also see postings
> advocating Ruby, and I know that some Pythonistas are quite interested in
> it.

Some Perl folk too.  And that's as it should be; use the right tool for
the job regardless of dogma.

> I looked at Ruby, briefly, and didn't really like the flavor as much as
> Python. Unless I'm thinking of another language altogether the syntax is
> warty, with a Perl-ish use of punctuation which might make programs shorter,
> but doesn't help with comprehension.

Umm, that's not *quite* right.  It does happen to have some Perl-like
shortcuts, but I view those as training wheels for folks coming to Ruby
from Perl.

I personally like the style and dynacism of Ruby.  For instance, to declare
a class that inherits from another class you simply have:

class Foo < Bar
	def myMethod
		File.new ("test.dat", "w") { |f| 
			f.puts "Hello world!"
		}
	end
end

Here, class Foo inherits from class Bar.  Except that class Bar is just an
expression that returns a Class object.  In this case it's a constant, but
you could just as easily have:

class Foo < someMagicRoutine(someArgument, somethingElse)

File is a real object, we'll call open on it.  The opened file object is
passed to the block as local variable f, where we can call puts (named as
in libc) to put a string to the file.  At the conclusion of the block,
the file is closed automatically.

Doesn't look much like Perl to me.  Oh, and that's just one way to 
use files -- you don't have to use them in a block, but I find it
handy to make sure I've really closed a file :-)


/\ndy

--
Andrew Hunt, The Pragmatic Programmers, LLC.
Innovative Object-Oriented Software Development
web:   http://www.pragmaticprogrammer.com   email: andy at pragmaticprogrammer.com
--
Books by Andrew Hunt and David Thomas:
    "The Pragmatic Programmer" (Addison-Wesley 2000)
    "Programming Ruby" (Addison-Wesley 2001)
--



More information about the Python-list mailing list