SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Confused about ruby in itself (not rails).

    The past couple days I've been playing with ruby because I want to learn rails but I feel that if I have a full understanding of ruby then it will make the task of fully understanding rails a lot simpler (I tried learning rails and got about half-way through Sitepoint's Simply Rails 2 2nd Edition and decided I wasn't understanding it well enough). So, I started to write programs, (I've done a little coding in Python and C++ but I never actually used it for anything practical, just playing around as I am now with ruby) and I've noticed that the code is extremely simple and I no longer have to remember things but rather my time is spent thinking logically about how a program should run, which is how I feel it should be. So far, I love ruby.

    I've written a program that I want to show my friend who is not a ruby developer and figured I should just make the .rb into a .exe so I could show him. I discovered that (as far as I know) there is no way to change a .rb into a .exe. I looked up how to do it and I came across someone who was asking a similar question on another forum but the only response was one that was basically saying "Why would you want to do that, it's pointless". I don't understand what he meant. Am I misunderstanding the purpose of ruby? What is the actual purpose for ruby if it is not to make programs that can run as standalone projects?

    I looked into RubyScript2Exe but it appears to only work with older versions of ruby.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fashionnugget View Post
    What is the actual purpose for ruby if it is not to make programs that can run as standalone projects?
    Any website you create with Ruby on Rails won't be a standalone executable; every single page request has to run through a Ruby interpreter. So there's an example of a purpose other than a standalone executable.

    It's not uncommon. This website, along with every other site built with PHP, only works when a PHP interpreter is available on the computer running the site.

  3. #3
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    Any website you create with Ruby on Rails won't be a standalone executable.
    Quote Originally Posted by Dan Grossman View Post
    I never mentioned Rails.
    That's why I was confused. I believe you meant Ruby not Ruby on Rails in your first post.

    Thanks for the responses guys, I now understand.

  4. #4
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I appreciate you're response but read my subject title again. I'm asking about the plane programming language ruby not ruby on rails. Does ruby also only exist for the purpose of web development?

    Basically I am asking what was ruby for prior to the release of ruby on rails.

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes I read your subject, I never mentioned Rails (you don't need Rails to run Ruby code on a web server), and the answer is the same. Ruby is an interpreted language, it was made to be run in an interpreter.

    Bash and Perl are also almost always run as interpreted code, yet programs written in these languages make up a large portion of the standard software in any Linux/Unix system. Those computers only run the Bash/Perl code because the Bash and Perl interpreters are installed. Same goes for Java programs and the Java VM (a bytecode interpreter), C# code and the .NET libraries, etc.

    *Most* desktop software has external dependencies, that's why software comes with installer programs. The installers are written in native executable code, and put all those dependencies on the computer the actual program needs to run, since it's not really self-contained at all.

    You can write non-web software in Ruby, it just requires the Ruby interpreter be available on the computers you want to run it on.

    You could write an installer for your friend, in a language that you can compile into a Windows binary, which installs the Ruby interpreter and creates a shortcut to run your program which launches the interpreter with your code as the input.

  6. #6
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're misunderstanding Ruby.

    Basically languages come in compiled or interpreted flavors (yes, that's perhaps oversimplifting it, but bear with me). Compiled languages are developed in an edit-compile-run cycle, meaning you have to build everything, turn everything into an executable before you can run it. Interpreted languages (often called scripting languages) are developed in an edit-run cycle -- as soon as you finish editing it you can run it.

    Compiled languages create a standalone executable (again this is simplified to make the point) while the interpreted languages always need the interpreter, because they are never saved in any form except source.

    Ruby is an interpreted language, meaning the programs you write in it never were intended to reach executable form. There are a lot of languages out there like this, starting with the venerable perl, going on through PHP, Java, Python and more other examples than I have time to enumerate. (Note: some of these talk about "compiling" but that's only to a psuedocode that still needs a run-time interpreter to execute.)

    Lately there have been some attempts to create portable executables from Ruby (MacRuby comes immediately to mind) that are standalone apps. Maybe there will be some more of these.

    Yes, ruby programs are intended to be shared/distributed. In source form, to be run on systems with ruby interpreters. (Ruby interpreters are free downloads, so if the program is good enough, there isn't a problem getting an interpreter to run it.)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •