<prosys / chartermi.net> wrote in message
news:200308162229.16796.prosys / chartermi.net...

> I understand that Ruby is being developed towards the realization
> of a VM for byte-code execution.  My question is, will the
> interpreter function of Ruby remain?  Will I be able to have the
> best of both worlds -- rapid development _and_ performance?

Ruby will be faster as it matures, but it will not give you real
performance. In some cases the C-compiled libraries can be scripted in a way
that is very fast (e.g. by having a fast regular expression matcher and fast
hash table) but generally Ruby is not and will not be as fast as statically
typed compiled languages.

Very often Ruby is fast enough. For many applications it completes the job
instantly.  Ruby allows you to write a lot of programs you would otherwise
never bother to write. It has a very friendly syntax. The major problem with
Ruby (and scripting in general) is deployment - you need an interpreter to
run a Ruby script.

> disappointed to see Ruby rated as low as it was in performance.
> This is the only reason I have not yet adopted Ruby.

It is fast enough for many purposes and it is certainly in my toolbox. Given
how easy it is to get started, it is worth learning Ruby even if you can't
use it for everything.

> I did notice OCaml (Objective Caml) at the top of the list --
> right up there with C.  And, in my investigation, I discovered

You should generally assume that C is twice as fast as OCaml although it
differs.
OCaml may sometimes lack easily accessible libraries but it has good
standard libraries.

> the OCaml can be run as a script interpreter _and_ that it can
> also compile byte-code and native code!  Wow -- just what I've
> been looking for.  But for some strange reason, I am still drawn
> to Ruby.

OCaml is also in my toolbox. It takes much more effort to get comfortable
with OCaml, but you can write even shorter programs than in Ruby. The syntax
is efficient but not friendly.

It is very important to me that OCaml compiles to object code that can link
directly with C code. If you take the time to understand the relatively easy
C call interface you can use OCaml for serious programming. Ruby also
interacts well with C, but you can take an OCaml executable and run it
everywhere. It takes up 200-300K.

I like Ruby more than OCaml but OCaml is a better tool for hardcore
development.

> Could someone please offer a comparison between OCaml and Ruby?

Here is a posting I wrote a year ago

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/45787

featured in Ruby Weekly News :-)
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/46348

OCaml is especially efficient in writing compilers. You get a productivity
boost of more than a factor 10 over C++ and the runtime is probably at least
as fast in this scenario.

I recommend both Ruby and OCaml. The effort in learning Ruby will be 10% of
that learning OCaml so you get Ruby for free. Ruby does things in a
different way and it depends on the task at hand.

I would use OCaml for heavily loaded web servers because Ruby isn't fast
enough, but I would use Ruby to prepare data offline for the same server
because it is so flexible and easy to update.

Mikkel