Ruby questions

J

Jeff M.

Hello, peeps. I'm dipping my feet into Ruby waters (from Smalltalk).
Just have some questions that I hope someone doesn't mind answering.
I'm on OS X 10.5.

I see that Ruby 1.9 is out and Leopard shipped with 1.8.6. I also
heard that 1.9 would introduce a new VM that would be significantly
faster than 1.8. Is that the case? If so, is there a standard way of
getting 1.9 on OS X or am I kinda stuck waiting for Apple to "do their
thing"?

I'm primarily playing around with GLUT and OpenGL in Ruby for fun.
This required getting ruby-opengl through gems (note: I think the idea
of gems is slick!). However, if I ever wanted to distribute my code or
a program, is there a proper way of distributing everything needed
with it? Is there a way of generating native executables or at least
combining the ruby executable with the source so that 2 years from now
my program still runs the same even though I have version 3.8 of ruby?

Perhaps I've missed this in documentation, but am I able to extend a
class without subclassing? Something akin to "loose methods" in
Smalltalk?

Anyway, thanks for taking the time to read/answer any of these. I
appreciate it.

Jeff M.
 
J

Jan Dvorak

I'm primarily playing around with GLUT and OpenGL in Ruby for fun.
This required getting ruby-opengl through gems (note: I think the idea
of gems is slick!). However, if I ever wanted to distribute my code or
a program, is there a proper way of distributing everything needed
with it? Is there a way of generating native executables or at least
combining the ruby executable with the source so that 2 years from now
my program still runs the same even though I have version 3.8 of ruby?

Try rubyscript2exe for this, it builds binary with your script, ruby
interpreter and required extensions and libraries inside.

Jan
 
J

James Gray

Hello, peeps. I'm dipping my feet into Ruby waters (from Smalltalk).

Hello and welcome to Ruby.
I see that Ruby 1.9 is out and Leopard shipped with 1.8.6. I also
heard that 1.9 would introduce a new VM that would be significantly
faster than 1.8. Is that the case?

It is faster in many cases, slightly slower in a few, and similar
speed in some others.
If so, is there a standard way of getting 1.9 on OS X or am I kinda
stuck waiting for Apple to "do their thing"?

The important thing to know is that Ruby 1.9 is currently a
"development release." It has known problems. The core team is
sorting those out, but it's going to take a little time to firm up.
Thus, as a new user, I recommend you stick with 1.8.6 for now to avoid
running into any of these issues.

To answer your question though: you do not have to wait for Apple to
upgrade Ruby for you, no. Many of us keep our own build (in /usr/
local) and update it as we desire.
However, if I ever wanted to distribute my code or
a program, is there a proper way of distributing everything needed
with it?

Short answer: yes.

Longer answer: how you handle this depends on how you distribute your
software. Gems can have dependencies, for example. There are also
some all-in-one-executable solutions.
Perhaps I've missed this in documentation, but am I able to extend a
class without subclassing? Something akin to "loose methods" in
Smalltalk?

Sure. Ruby has open classes, so we can add methods to them at any time:

$ irb=> "Wnzrf Rqjneq Tenl VV"

Hope that helps.

James Edward Gray II
 
J

Joe

Hello, peeps. I'm dipping my feet into Ruby waters (from Smalltalk).
Just have some questions that I hope someone doesn't mind answering.
I'm on OS X 10.5.

I see that Ruby 1.9 is out and Leopard shipped with 1.8.6. I also
heard that 1.9 would introduce a new VM that would be significantly
faster than 1.8. Is that the case? If so, is there a standard way of
getting 1.9 on OS X or am I kinda stuck waiting for Apple to "do their
thing"?

I'm primarily playing around with GLUT and OpenGL in Ruby for fun.
This required getting ruby-opengl through gems (note: I think the idea
of gems is slick!). However, if I ever wanted to distribute my code or
a program, is there a proper way of distributing everything needed
with it? Is there a way of generating native executables or at least
combining the ruby executable with the source so that 2 years from now
my program still runs the same even though I have version 3.8 of ruby?

rubyscript2exe is windows only.
there is a package to make it a tar, but the user will still have to
install the gems you depend on if I understand it correctly.

Honestly, the best way I've seen to distribute a ruby app to actual
users that I've seen is JRuby. Compile your program to java bytecode
and you can distribute it in a jar.

The last time this came up some people talked about starkits in tcl,
and suggested something like that for ruby, but it didn't really go
anywhere.

I believe one of the goals in rubinius is to have something similar to
jar for ruby, but i could be wrong about that.
 
J

Joe

sorry, my mistake. The name of it always makes me think windows only.
It can run on all platforms, but it's not a cross platform solution.
The exe generated is only for the platform it's running on.
 
J

Jan Dvorak

Honestly, the best way I've seen to distribute a ruby app to actual
users that I've seen is JRuby. Compile your program to java bytecode
and you can distribute it in a jar.
What about extensions ? (ruby-opengl in this case)
sorry, my mistake. The name of it always makes me think windows only.
It can run on all platforms, but it's not a cross platform solution.
The exe generated is only for the platform it's running on.

Technically speaking this is not cross-platform solution either, as the
bytecode runs only on the Java platform. For distribution you're just trading
dependency on ruby interpreter for dependency on java bytecode interpreter.

Tools like rubyscript2exe will get you OS-dependent binary, but it is
self-sustained and will run without any other dependencies.

Jan
 
J

Joe

What about extensions ? (ruby-opengl in this case)

Java OpenGL extensions are available. I don't mean to push JRuby so
hard, but when looking for a good distribution mechanism a while back
it's the best i could find. It'd also work on platforms I don't own.
I don't have a mac, but I'd like software i write to be able to run on
it. I don't expect my users to use the command line to start the
program. I guess other people have different requirements.
Technically speaking this is not cross-platform solution either, as the
bytecode runs only on the Java platform. For distribution you're just trading
dependency on ruby interpreter for dependency on java bytecode interpreter.

Tools like rubyscript2exe will get you OS-dependent binary, but it is
self-sustained and will run without any other dependencies.

I guess I should have said OS independent. I'd like for something in
ruby to be similar to the jar, but it hasn't seem to emerged yet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top