Some General Questions about Ruby

V

Vinh Chuc

Hi !
I think i'll soon begin to learn programming in ruby, as so many people
find it ( and its buddy RoR ) awesome.
I'm a beginner programmer ( Basic, PHP, Caml, and i'm currently reading
some C/C++ tutorials )

Ruby is an interpreted language, if i'm not wrong, interpreted languages
are slightly slower than compiled ones,
so far i mainly coded web apps, but i may one day do some Desktop apps
programming, and so : are Ruby programs much slower/nearly as fast/ ...
as a for example a C-compiled program ( i guess it depends a lot on the
kind of software ) ??

About the possibilities of Ruby, i know Ruby is a generic language, and
that we can program almost every software in Ruby, but *almost* every
for example, is it possible to develop a peripheral driver in Ruby ??
more generally to access the hardware ? to write a linux kernel module
?? ( i guess it is not possible to write a ruby OS kernel )

thank you

( i'm not a native english speaker, sorry if any mistakes )
 
F

François Montel

Vinh said:
are Ruby programs much slower/nearly as fast/ ...
as a for example a C-compiled program ( i guess it depends a lot on the
kind of software ) ??

Yes, Ruby is quite a bit slower than C. But depending on the program
you're writing, this may not make much/any difference to the end user.
If there are certain parts of the program that are creating a major
performance hit, you can always write those bits in C and then call your
C module from Ruby.
 
C

Chad Perrin

Hi !
I think i'll soon begin to learn programming in ruby, as so many people
find it ( and its buddy RoR ) awesome.
I'm a beginner programmer ( Basic, PHP, Caml, and i'm currently reading
some C/C++ tutorials )

That's a pretty good beginning -- three languages plus some dabbling.

Ruby is an interpreted language, if i'm not wrong, interpreted languages
are slightly slower than compiled ones,
so far i mainly coded web apps, but i may one day do some Desktop apps
programming, and so : are Ruby programs much slower/nearly as fast/ ...
as a for example a C-compiled program ( i guess it depends a lot on the
kind of software ) ??

Technically, it's not the language that's slower -- it's the
implementation. It's true that, all else being equal, intepreted code
runs more slowly than code compiled to a binary executable, but whether
it is interpreted or compiled depends on the implementation you're
using. For instance, Objective Caml (aka OCaml) allows you to execute
code via an interpreter, to compile to bytecode and run in a VM, or to
compile to an executable binary file native to the platform.

Ruby, of course, is a rather more dynamic language than OCaml, and as
such is not (thus far) really suitable to compilation. As such, it is
executed via an interpreter, and it's not a very fast interpreter. I'm
mostly just being pedantic here, but I figured I may as well make the
situation as crystal clear as is reasonable.

In any case, Ruby can definitely be used for desktop application
development. You just have to be sure you know where execution speed
will impose an unacceptable bottleneck, and perhaps choose a different
language in such circumstances. For instance, I don't think I'd want
to implement a Mathematica clone entirely in Ruby, but a light weight
word processor or web browser should be fine.

About the possibilities of Ruby, i know Ruby is a generic language, and
that we can program almost every software in Ruby, but *almost* every
for example, is it possible to develop a peripheral driver in Ruby ??
more generally to access the hardware ? to write a linux kernel module
?? ( i guess it is not possible to write a ruby OS kernel )

I'd recommend against writing hardware drivers in Ruby, generally
speaking, though I imagine it's possible. Writing an OS kernel might
prove a bit more difficult, with the interpreter-only implementation(s)
currently available. For that sort of thing, you probably want to stick
to something like C, OCaml, or maybe even Haskell or compiled Lisp.
Ruby (and even Perl) is a bit less practical for such purposes.
 
J

John Browning

Quick answers:

much slower, but for Web apps and a lot of other interactive apps
where input/output itself creates lots of delays and lots of waiting,
you probably don't care.

It's possible to do most or all of those things in Ruby -- apart from
the kernel module -- but you don't want to. One reason: an
interpreted language to execute has to bring with it the whole
interpreter, which makes it large. Second, which should probably be
first, speed matters much more in things like peripheral drivers
which lots of other programs use and thus can be chokepoints for the
whole system.

Ruby on Rails is slow even by the standards of Web applications. But
it's still well worth learning as it makes it much easier to develop
-- and more importantly to evolve -- powerful applications.

Good luck.
 
V

Vinh Chuc

thanks !
@Chad Perrin
when i said i was a beginner programmer i meant in the desktop softwares
field ;), as so far i mainly coded in php, and maths algorithms with
caml

when i asked if it was possible to develop OS kernels/modules, i am
aware that "i don't want to", as it would imply that the kernel includes
the interpreter, that itself has a bunch of prerequisites
but from a theorical point of view, is it possible ? ( can ruby deal
with hardware access, memory management etc ... )




I have another question, about the WxRuby toolkit, i never used a gui
toolkit before, but i guess it works like that :
_ for a compiled program ( for example C/C++ ), the toolkit library, is
either already installed on the end user computer, either it is
"included" in the source code and compiled with it
_ but for an interpreted language, how does it work ??? do the end user
have to install a specific wxwidgets library ? or does wxruby provide a
file that we have to bundle with the .rb files ????

thanks again
 
B

Brian Candler

I'd recommend against writing hardware drivers in Ruby, generally
speaking, though I imagine it's possible. Writing an OS kernel might
prove a bit more difficult, with the interpreter-only implementation(s)
currently available. For that sort of thing, you probably want to stick
to something like C, OCaml, or maybe even Haskell or compiled Lisp.
Ruby (and even Perl) is a bit less practical for such purposes.

Although there are specific places where userland programs are intended to
hook into the kernel, and Ruby is fine for such things. For example, using
ruby fusefs you can write your own filesystem in Ruby.
http://rubyforge.org/projects/fusefs/
 
C

Chad Perrin

Although there are specific places where userland programs are intended to
hook into the kernel, and Ruby is fine for such things. For example, using
ruby fusefs you can write your own filesystem in Ruby.
http://rubyforge.org/projects/fusefs/

Agreed. I didn't mean to suggest that you shouldn't interact with the
kernel with Ruby -- just that it's usually not the best language for
interacting directly with hardware and writing low-level stuff like
most Linux kernel modules (for instance).
 
V

Vinh Chuc

ok, thanks, i know that ruby is not aimed at developing kernel related
programs, it was just to know if it was theorically possible
bye !
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top