Newbie Qs: startup time, Module.constants, chdir, Ruby distro's library

Hello there!

I’m new to Ruby and my first impressions are really good: after some
experience with both Perl and Python, the clean OO-ness of Ruby has been
exciting, not to talk about its “no surprises” approach.

My first questions are of various kind, please apologize me for mixing
them in a single message:

  1. on my monster PC (a glorious 200mhz Pentium box with W98…), Ruby’s
    startup time is about 1 second (e.g., ruby -e “p ‘hello world’” takes 1
    second) Isn’t it too much?
    Using IRB is even worse: it takes about 2/3 seconds to show the first
    prompt, and about 0.5 seconds to process every line. Is this normal? Is
    it time for me to think to a Pentium II? :slight_smile:
    I’m using Ruby 1.6.7, installed from ruby-1.6.7-i586-mswin32.zip (sorry,
    I don’t remember the exact version of the executable I downloaded, but
    it’s the one which does not require Cygwin or other support environments)

  2. after browsing the Pragmatic Programmer’s Guide, I did some tests with
    Module.constants and Module#constants. Now I really don’t understand the
    following:

module M
Konst1=1
end

M.constants

[‘Konst1’]

class C
Konst2=1
end

C.constants

[“Konst2”, “DATA”, “FALSE”, “ARGV”, …]

Why the different behaviour? I mean, why #constants returns just a
module’s own constans, and a class’ own and inherited constants?

There is also the fact that:

M::DATA

#<File:0x257cc5c>

C::DATA

#<File:0x257cc5c>

Since DATA is accessible through M (as well as all other consts),
shouldn’t M.constants include it (together with all other consts)?

I’ve read about the C.constants-C.superclass.constants trick, my problem
is not finding a way to discover C’s own constants, I just would like to
understand #constants has a different behaviour when it is applied to a
module or a class.

2bis) To understand when Module.constants and Module#constants are
called, I used:

class Module
alias oldc constants
def constants
puts "constants"
oldc
end
class <<self
alias oldmc constants
def constants
puts "Module.constants"
oldmc
end
end
end

Is this right? is is the right way to do it?

  1. If I want to use a script to persistently (i.e., after Ruby’s
    exit) change the working dir, how do I do? Neither

ruby -e “system(‘cd \’); puts Dir.getwd”

nor

ruby -e “Dir.chdir(’\’); puts Dir.getwd”

seem to work

  1. Comparing Ruby with the Pythonesque “batteries included” approach
    wasn’t very exciting… At times I think that Python (ActiveState) distro
    is overloaded, but all in all I prefer too many (optional) features than
    too few. Is there a reference Ruby library? Are there distros supporting
    it?

That’s all for now. My compliments to Matz, I really like the language,
its simplicity and its object orientation, definitely one step above the
competition.

And thank you in advance for your help.

Andrea (which, FYI, is a male name here in Italy :slight_smile: )

Newsgroups: comp.lang.ruby

···

----- Original Message -----
From: “Overnight” <NOSPAM_jazz_x@libero.it_NOSPAM.web-hosting.com>
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, September 04, 2002 5:45 PM
Subject: Newbie Qs: startup time, Module.constants, chdir, Ruby distro’s
library

  1. on my monster PC (a glorious 200mhz Pentium box with W98…), Ruby’s
    startup time is about 1 second (e.g., ruby -e “p ‘hello world’” takes 1
    second) Isn’t it too much?
    Using IRB is even worse: it takes about 2/3 seconds to show the first
    prompt, and about 0.5 seconds to process every line. Is this normal? Is
    it time for me to think to a Pentium II? :slight_smile:
    I’m using Ruby 1.6.7, installed from ruby-1.6.7-i586-mswin32.zip (sorry,
    I don’t remember the exact version of the executable I downloaded, but
    it’s the one which does not require Cygwin or other support environments)

I do think Ruby has a slow startup time. Probably worse on
Windows, probably worse still on a slow box like yours (or
mine).

  1. after browsing the Pragmatic Programmer’s Guide, I did some tests with
    Module.constants and Module#constants. Now I really don’t understand the
    following:

My short answer is that classes can inherit from other classes,
but a module can’t inherit from anything. Maybe there is a
better explanation.

Andrea (which, FYI, is a male name here in Italy :slight_smile: )

Of course, as in Andrea del Sarto… :wink:

Hal

Overnight wrote:

  1. Comparing Ruby with the Pythonesque “batteries included” approach
    wasn’t very exciting… At times I think that Python (ActiveState) distro
    is overloaded, but all in all I prefer too many (optional) features than
    too few. Is there a reference Ruby library? Are there distros supporting
    it?

Do you know about Andy Hunt’s distribution for Ruby-on-Windows?

http://www.pragmaticprogrammer.com/ruby/downloads/ruby-install.html

I don’t know that it is yet up to the level of the ActivePython distro
but it’s got a lot of good (extra) stuff in it.