0

I have been messing around with ruby on rails. But my questions is really simple. Is ruby used language used for desktop applications? I mean without Rails? Can it be combined with GUI packages and Graphics Libraries to create a game for example? I have read that ruby is based on C. So it will be fast right?

Test Test
  • 2,831
  • 8
  • 44
  • 64
  • 2
    Yes, yes it is. Please try to ask one question per question. – user229044 May 10 '12 at 17:55
  • see http://stackoverflow.com/questions/260905/whats-the-best-easiest-gui-library-for-ruby – Baldrick May 10 '12 at 17:56
  • Ruby is a great language, but not as fast as you'd expect for gaming considering it's interpreted. – MilkyWayJoe May 10 '12 at 17:56
  • 3
    I have heard computers are based on electricity. Electricity is fast. Therefore, all computers are fast. See the fallacy? The question is, is Ruby *fast enough*? And, in many cases, it is. It doesn't matter what language it [Ruby] was written in (actually, [JRuby](http://jruby.org/), Ruby written in Java, [is faster that the C MRI in cases](http://shootout.alioth.debian.org/u64q/which-programming-languages-are-fastest.php)). –  May 10 '12 at 17:57
  • See [With what tools can I make a complex and advanced GUI with Ruby?](https://softwarerecs.stackexchange.com/q/53553/36725). – sondra.kinsey Apr 10 '19 at 00:35

4 Answers4

16

Is ruby used language used for desktop applications?

Yes it is.

I mean without Rails?

Yes.

Can it be combined with GUI packages and Graphics Libraries to create a game for example?

Yes it can be.

I have read that ruby is based on C. So it will be fast right?

No, it won't be "fast" in the same way C is fast, because that isn't the point of Ruby. Ruby isn't "based on" C in any sense. The interpreter which runs Ruby code may be written in C (there are many interpreters and not all of them are), but that has nothing to do with the language itself. C and Ruby are not really comparable and occupy completely different niches.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • I wish I could vote twice for this – MilkyWayJoe May 10 '12 at 18:00
  • 3
    Ruby is generally not "C fast" when number crunching, etc. However, when coupled with a relatively slow user (most of the time computers wait on *us* ;-), it can very well be "fast enough". –  May 10 '12 at 18:05
  • Actually, the Rubinius `Hash` class, which is written in Ruby is faster than the YARV `Hash` class which is written in C. So, this is at least one example where Ruby is *faster* than C. – Jörg W Mittag May 11 '12 at 02:04
  • @JörgWMittag The fact that you have to prove that there is *at least* one example kind of proves our point. – user229044 May 11 '12 at 03:28
3

I've no experience in programs where speed is critical; however, from my experience, Ruby is fast enough for user applications with GUI, and differences are almost unnoticeable from other similar dynamical languages (Ruby 1.9 is even faster, sometimes).

There is a reason I don't name the "similar languages": I think languages benchmarks aren't useful at all. While the fact that Ruby is fast enough for general purpose programming will probably make you happy, I think it's more important that if you already know and like Ruby you will be more productive using it.

There are some limit cases Ruby will be even faster than C: your implementations in C for functions that are offered as methods in the Ruby core lang and std lib could be slower than the ones in Ruby VM. This is just to say, speed isn't usually a concern, unless you're actually well aware of a particular reason you should be concerned with speed.

Some nice GUI libraries are FXRuby and Shoes, a very easy library used in the Hackety Hack project to teach children to program. I usually use Tk when programming with Ruby and Python because it's included in the standard library and there is no need to install anything else.

For Gaming, you can try Gosu and Chingu; Gosu is probably the most actively developed Ruby Gaming Library, and Chingu is a nice collection of classes based on the foundations offered by Gosu. They've not got the nice community of other gaming libraries (e.g. Pygame) but you can easily start making little games with them.

Alberto Moriconi
  • 1,645
  • 10
  • 17
1

Check out the Shoes GUI, it has different implementations, each one has a colorname, the most popular ared Red and Green Shoes, they are often used to make the kind of games you see also in Flash or regular javascript. They are fast enough for that kind of games. Some implementations even work with JRuby.

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
peter
  • 41,770
  • 5
  • 64
  • 108
0

Ruby is a language whose common implementation (e.g. ruby-1.9.3-pl94) is an interpreter coded in C. File main.c contains the main function in C which set up the Ruby VM implemented in C in file vm.c.

You could have several implementations of Ruby. I heard that some people wanted to re-implement Ruby above the Parrot VM (itself implemented in C); but that effort is perhaps still in progress. JRuby is a Ruby above the JVM.

Indeed interpreter vs compiler is not a sharp difference. Many interpreters contain a virtual machine with a translator (which you could view as a compiler) to that VM. Some VM implementations have a Just In Time dynamic translator to machine code. The JIT part produces machine code dynamically.

You could code a graphical application using e.g. Ruby-Gnome, a glue to Gnome and Gtk. You could also use Ruby Qt, a glue to KDE and Qt

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • 1
    -1 for so many reasons. First off, there is no such thing as an interpreted language (and even if there were, then Ruby wouldn't be one, since almost every single Ruby implementation has a compiler). Secondly, there is no such thing as "its implementation", there many implementations. And thirdly, the vast majority of Ruby implementations are not written in C. – Jörg W Mittag May 11 '12 at 02:06
  • "Maybe some people tried a Ruby above JVM thing." Nice FUD. [Do or do not. There is no try](http://jruby.org/). – Andrew Grimm May 11 '12 at 05:32
  • Corrected with your link – Basile Starynkevitch May 11 '12 at 05:34