Newbie Qs: startup time, Module.constants, chdir, Ruby distro's library 
Author Message
 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? :-)
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:

Quote:
> module M
>    Konst1=1
> end

> M.constants

['Konst1']

Quote:
> 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:

Quote:
> M::DATA

#<File:0x257cc5c>

Quote:
> 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?

3) 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

4) 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 :-) )



Mon, 21 Feb 2005 06:27:09 GMT  
 Newbie Qs: startup time, Module.constants, chdir, Ruby distro's library
Quote:
----- Original Message -----

Newsgroups: comp.lang.ruby

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? :-)
> 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).

> 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:

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 :-) )

Of course, as in Andrea del Sarto... ;)

Hal



Mon, 21 Feb 2005 06:56:06 GMT  
 Newbie Qs: startup time, Module.constants, chdir, Ruby distro's library

Quote:

> 4) 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.



Mon, 21 Feb 2005 21:50:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Time constants module - standard-library fodder?

2. self-loading scripts (at Ruby's startup time)

3. Can't translate PICK at startup time

4. Can't translate PICK at startup time

5. Bug in chdir() in Ruby 1.6....

6. Ruby library modules and documentation

7. Qs re 'Write & 'Read

8. Newbie Help: Dynamic 'import' of modules

9. AttributeError with 'time' module

10. New newbies Qs on Ruby

11. Qs on Ruby and DbC/Smalltalk

12. Problems loading a module linked with real-time and pthread libraries

 

 
Powered by phpBB® Forum Software