From: Stefano Crocco Date: 2012-05-13T01:02:49+09:00 Subject: Re: Beginner's questions Il giorno Sun, 13 May 2012 00:34:13 +0900 Manfredi Pivetta ha scritto: > Hello everyone. > I've recently picked up programming languages yet again, and since I've > spent some time on Ruby in the past already, I've decided to start from > here. However, I've encountered some problems. I've gone through > at least three tutorials already, but they are kind of useless at this > stage for me because they all focus on teaching the syntax and how to > code, while I'm stuck mostly on the tools and libraries. So, here are > my questions; feel free to redirect me towards a proper tutorial if you > wish (as long as the tutorial actually has the information I need...). > > First question. How do I compile Ruby code on Linux? You don't. Ruby is an interpreted language (like shell script, for example) so you don't need to compile a program to use it. From a terminal you just write: ruby myscript.rb and it'll run. You can also add the line #!/usr/bin/ruby at the beginning of the script, make it executable (using chmod) and run it as ./myscript.rb > > Second question. How do I work with a graphic interface? Is there a > library? If there is a library, is there a reference manual for the > library? I don't require big things, but I've never been able to > actually produce a graphical output, and tutorials do not help in any > meaningful way. I've learned to create even quite complex programs in C, > but they were always on the terminal and the most interesting graphical > output command I had was printf. Since I'm trying to write a program for > some elementary kids, I'd rather avoid the terminal altogether. Ruby comes with bindings to the Tk library. You can find some documentation at [1]. There are also bindings for other graphics libraries, such as Qt [2], Gtk [3] and WxWidgets [4]. You can most likely find packages for them using your distribution's package manager. > Third question. If I compile a ruby program, how can I make sure that > double clicking on it will make it run properly (and activate the above > mentioned user interface)? Again, I'm used to executing programs from > the terminal but I'd rather have something much much simpler for this > project. Do you have any advice? That depends on the desktop environment you use. > I understand these are some pretty stupid questions, but they got me > stuck for quite a while and I have noone to ask them to. :) > [1] http://www.tkdocs.com/tutorial/index.html [2] http://techbase.kde.org/Development/Languages/Ruby [3] http://ruby-gnome2.sourceforge.jp/ [4] http://wxruby.rubyforge.org/wiki/wiki.pl