Ruby questions

Discussion in 'Ruby' started by Jeff M., Jan 8, 2008.

  1. Jeff M.

    Jeff M. Guest

    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.
    Jeff M., Jan 8, 2008
    #1
    1. Advertising

  2. Jeff M.

    Jan Dvorak Guest

    On Tuesday 08 January 2008 20:05:03 Jeff M. wrote:
    > 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
    Jan Dvorak, Jan 8, 2008
    #2
    1. Advertising

  3. Jeff M.

    James Gray Guest

    On Jan 8, 2008, at 1:05 PM, Jeff M. wrote:

    > 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
    >> class String
    >> def to_rot13
    >> tr 'a-zA-Z', 'n-za-mN-ZA-M'
    >> end
    >> end

    => nil
    >> "James Edward Gray II".to_rot13

    => "Wnzrf Rqjneq Tenl VV"

    Hope that helps.

    James Edward Gray II
    James Gray, Jan 8, 2008
    #3
  4. Jeff M.

    Joe Guest

    On Jan 8, 2008 2:05 PM, Jeff M. <> wrote:
    > 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.
    >
    > 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.
    >
    >
    Joe, Jan 9, 2008
    #4
  5. Joe wrote:
    > rubyscript2exe is windows only.


    Works fine on linux.

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
    Joel VanderWerf, Jan 9, 2008
    #5
  6. Jeff M.

    Joe Guest

    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.

    On Jan 8, 2008 9:30 PM, Joel VanderWerf <> wrote:
    > Joe wrote:
    > > rubyscript2exe is windows only.

    >
    > Works fine on linux.
    >
    > --
    > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
    >
    >
    Joe, Jan 9, 2008
    #6
  7. Jeff M.

    Jan Dvorak Guest

    On Wednesday 09 January 2008 03:58:17 Joe wrote:
    > 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
    Jan Dvorak, Jan 9, 2008
    #7
  8. Jeff M.

    Joe Guest

    On Jan 8, 2008 10:41 PM, Jan Dvorak <> wrote:
    > On Wednesday 09 January 2008 03:58:17 Joe wrote:
    > > 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)


    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.

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


    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.

    >
    > Jan
    >
    >
    Joe, Jan 9, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ali Syed
    Replies:
    3
    Views:
    545
    Mark McIntyre
    Oct 13, 2004
  2. pkirk25
    Replies:
    50
    Views:
    1,094
    Bill Pursell
    Oct 4, 2006
  3. Replies:
    10
    Views:
    538
  4. Charles Comstock
    Replies:
    1
    Views:
    111
    Lyle Johnson
    Jun 25, 2004
  5. anne001
    Replies:
    1
    Views:
    402
Loading...

Share This Page