You are not logged in.

#1 2005-08-03 23:23:11

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Why is Ruby so small?

Okay, this should sum up my question nicely. It's the sizes of the tarred and gzipped binary packages for various languages, in order of decreasing size:

j2re - 29.3 MB
mono - 20.2 MB
perl - 11.8 MB
python - 9.9 MB
ruby - 2.4 MB

Does Ruby lack a lot of the features found in Perl and Python, or something?

Offline

#2 2005-08-04 01:06:50

jellywerker
Member
From: Sunny Seattle
Registered: 2005-04-04
Posts: 286

Re: Why is Ruby so small?

no, it just just made far cleaner than the other languages, and lacks some libraries I believe.

Offline

#3 2005-08-04 07:24:31

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Why is Ruby so small?

I dont think that Ruby has a standard library as big and complete as that of python.

iphitus

Offline

#4 2005-08-04 11:35:37

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Why is Ruby so small?

I agree - the language itself is well featured, but not as many modules included as Perl and Python.

Mono and Java contain a massive core API. Java includes its own GUI toolkit (2 in fact, AWT for applets and Swing for desktop apps) and Mono presumably comes with its gtk bindings.

Offline

#5 2005-08-04 15:01:59

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Why is Ruby so small?

Maybe one needs to compare just the binary interpreters for a better "size" comparison - /usr/bin/ruby, et al

Offline

#6 2005-08-04 15:10:44

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Why is Ruby so small?

right. Ruby includes things in the stdlib that make relative sense. If you need more functionality, you can use ruby gems. Gems is a system much like cpan.

Ruby also doesn't have alot of the cruft libraries that python has--old interfaces and such that are deprecated, but still hanging on..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#7 2005-08-04 15:56:14

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: Why is Ruby so small?

On the other hand it makes it easier to deploy Python apps than Ruby ones (I guess).

Offline

#8 2005-08-04 15:59:47

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Why is Ruby so small?

I suppose that argument could be made, and is indeed valid.
I guess I prefer a slightly smaller base package, with addons "as needed" for functionality above and beyond the norm.That is likely what drew me arch in the first place.To me, Ruby typifies the simplicity that I seek.

The "Ruby Way" and the "Arch Way" share facets that I find speak to the soul of my developer self. To each their own though. That is why there are mulitple languages and design constructs.

If we all thought the same, there would be little beauty in the world. smile


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#9 2005-08-04 16:14:16

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: Why is Ruby so small?

Is Ruby as easy to learn as Python? Can you start using it right away?

I don't care much about the size of a package because I don't think it's an issue any longer, now that we have broadband and all that. Maybe Java really is monstrous, but it makes deployment a breeze for the developers. As long as the language is kept clean (not too many builtin stuff and keywords) I think it'll work nicely.

And if anyone wants a summary - Python rocks, Ruby rocks. And ask Dusty about Java.

Offline

#10 2005-08-04 16:50:22

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Why is Ruby so small?

sweiss wrote:

Is Ruby as easy to learn as Python? Can you start using it right away?

I used both, and I would say that they are close to ease of learning. For a new programmer with no previous programming experience, it *might* be easier to pick up python. For anyone who has programmed anything before (even vb...lol) they are probably both equally easy to learn.

http://poignantguide.net/ruby/
http://www.rubycentral.com/book/

http://wiki.python.org/moin/BeginnersGuide
http://diveintopython.org/


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#11 2005-08-04 18:22:50

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: Why is Ruby so small?

What I love in python is the simplicity of dynamicly modfiying classes and in general all the information you can gain about objects at runtime. Is there something similar to ruby?

Offline

#12 2005-08-04 18:27:46

max_sipos
Member
From: Ithaca, NY
Registered: 2004-10-31
Posts: 106
Website

Re: Why is Ruby so small?

http://www.ruby-doc.org/stdlib/

Here is the reference of the ruby standard library. I never felt there was anything missing that would warrant being included with all distributions of ruby.

Offline

#13 2005-08-04 20:50:25

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: Why is Ruby so small?

cactus wrote:
sweiss wrote:

Is Ruby as easy to learn as Python? Can you start using it right away?

I used both, and I would say that they are close to ease of learning. For a new programmer with no previous programming experience, it *might* be easier to pick up python. For anyone who has programmed anything before (even vb...lol) they are probably both equally easy to learn.

http://poignantguide.net/ruby/
http://www.rubycentral.com/book/

http://wiki.python.org/moin/BeginnersGuide
http://diveintopython.org/

Thanks for the guides. Though I must say things like "puts" and "3.times" are pretty weird looking.

Offline

#14 2005-08-04 21:01:09

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Why is Ruby so small?

sweiss wrote:

Thanks for the guides. Though I must say things like "puts" and "3.times" are pretty weird looking.

Yeah, the 5.method thing gets me alot, but I think that's valid in alot of languages (javascript?) - puts is actually the name of the C function to output a constant string (though everyone uses printf, which is dumb).

The one thing I *hate* is the "puts" abbreviation (like it needs an abbreviation)

p 5

Offline

#15 2005-08-04 21:12:49

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: Why is Ruby so small?

I think I'll try to master Python still rather than starting with something new then smile

Offline

#16 2005-08-04 21:22:00

max_sipos
Member
From: Ithaca, NY
Registered: 2004-10-31
Posts: 106
Website

Re: Why is Ruby so small?

phrakture wrote:

The one thing I *hate* is the "puts" abbreviation (like it needs an abbreviation)

p 5

Actually, it's not an abbreviation. p calls the objects .inspect method to produce a more meaningful output. In that sense, it's really used as a debugging tool (perhaps in irb, that would explain its brevity). puts, on the other hand calls the objects to_s method, which may not be the ideal thing.
For an example, try this:

a = [1, 2, [3,4]]
p a
puts a

Array's to_s has no clue what to do, so it just propagates the to_s message to its members. inspect, on the other hand, tries to produce a more meaningful result.

As for the closures, they are definitely the most useful thing in the language, although the .times  method is the least useful example. You could also write a loop like

for i in 1..10 do
puts i
end

or 1.upto(10) {|i|
  puts i
}

Its truly useful applications come with various .each, .collect, .inject, as wel as the neat way of dealing with I/O objects.
-end rant-

Offline

#17 2005-08-05 11:17:37

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: Why is Ruby so small?

I think I only miss real closures from python, these expression-lambdas are a bit useless.

Offline

#18 2005-08-05 15:14:25

max_sipos
Member
From: Ithaca, NY
Registered: 2004-10-31
Posts: 106
Website

Re: Why is Ruby so small?

cmp wrote:

I think I only miss real closures from python, these expression-lambdas are a bit useless.

Eh? Mind explaining this a bit more?

Offline

#19 2005-08-05 15:47:14

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: Why is Ruby so small?

in python you can use lambda args: expression, to create sth. like a closure, but it can only contain one expression, not a block.
example:

lambda x,y: x+y
def add(x,y):
    return x  + y

these are the same, but if you want to set a member of a class to a value, you can't use obj.a = 2, because this is a statement, so you have to use tricks, like lambda: setattr(sefl, "a", 2).
but as I think about it, it's not that bad, because you can allways define a function (even inside a function), but still I would love a bit more stronger lambdas.

Offline

#20 2005-08-05 15:55:32

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Why is Ruby so small?

cmp wrote:

but as I think about it, it's not that bad, because you can allways define a function (even inside a function), but still I would love a bit more stronger lambdas.

Your issue seems to be with anonymous closures... "named" closures (what you said, create a function and throw it in a lambda) are easier.

It looks to me like this is by deisgn.

Offline

#21 2005-08-05 16:06:58

max_sipos
Member
From: Ithaca, NY
Registered: 2004-10-31
Posts: 106
Website

Re: Why is Ruby so small?

cmp wrote:

in python you can use lambda args: expression, to create sth. like a closure, but it can only contain one expression, not a block.
example:

lambda x,y: x+y
def add(x,y):
    return x  + y

these are the same, but if you want to set a member of a class to a value, you can't use obj.a = 2, because this is a statement, so you have to use tricks, like lambda: setattr(sefl, "a", 2).
but as I think about it, it's not that bad, because you can allways define a function (even inside a function), but still I would love a bit more stronger lambdas.

Oh, I see. I sort of misinterpreted your comment then smile.

So, once you create a named function, can you pass it to other functions and will it preserve the binding like when it was initially created?

Offline

#22 2005-08-08 23:06:56

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: Why is Ruby so small?

do you mean something like this:

>>> class Test:
...     def do(self):
...             print "hallo"
... 
>>> def test(a,b):
...     def sub():
...             print a
...             b.do()
...     return sub
... 
>>> s = test("hallo", Test())
>>> s()
hallo
hallo

Offline

#23 2005-08-10 02:36:54

max_sipos
Member
From: Ithaca, NY
Registered: 2004-10-31
Posts: 106
Website

Re: Why is Ruby so small?

cmp wrote:

do you mean something like this:

>>> class Test:
...     def do(self):
...             print "hallo"
... 
>>> def test(a,b):
...     def sub():
...             print a
...             b.do()
...     return sub
... 
>>> s = test("hallo", Test())
>>> s()
hallo
hallo

Yes, that's basically "C function pointer" functionality. However, what is really cool about closures in Ruby is that they get bound to the context they were defined in. For instance, doing something like:

a = 100
p = lambda {
    a
}

puts p.call()

will output 100. And any other time you call this function, you will get 100.

There is a small trick though: the closure remembers the binding references. It does not keep actual data. In case of fixnums, changing a later wouldn't make any change, but things could get complicated with other data.

This memory of the "context" of the closure is what makes it a real "closure".

So, I suppose, my question was if Python supported this sort of functionality.

Offline

#24 2005-08-10 11:59:03

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: Why is Ruby so small?

as you can see python has this functionality. a,b are contained in the scoped of the outer funktion (test) and are bound to the scope of the inner function (sub). and they remain bound even if the scope of the outer function is left.
another example:

>>> def test():
...     l = list()
...     def sub():
...             return l
...     return sub
... 
>>> s = test()
>>> s
<function sub at 0x40065f0c>
>>> s()
[]

or your example:

>>> def test():
...     a = 100
...     def p():
...             return a
...     return p
... 
>>> p = test()
>>> print p()
100

Offline

Board footer

Powered by FluxBB