Rite Implementation Idea

R

Ryan Paul

I just finished reading about Rite (thx to Mark for bringing it to my
attention, btw!), and I was wondering if there have been any significant
recent developments, or if there is a place where such developments are
chronicled. If ruby is in need of a new virtual machine, why not base it
on OCaml?

Ocaml has an immensely effecient virtual machine, and it also supports
generation of native binaries on many platforms. Additionally, it provides
a top-level interactive shell, and many mechanisms that vastly simplify
language creation, including a very powerful native parsing system based
on streams.

OCaml plays well with C, so using the OCaml virtual machine for Ruby would
probably make it easy to embed it in C programs, and use external C code
inside of it.

Ocaml also lets you do some really strange tricks that might give ruby
programmers more deployment options. I have seen OCaml parsers that
generate c/cpp ASTs, for instance, and I imagine that, using similar
methodology, it may eventually be possible to use an OCaml based ruby
parser to generate bytecode for java, parrot, and python VMs.
 
M

Mark Hubbart

I just finished reading about Rite (thx to Mark for bringing it to my
attention, btw!), and I was wondering if there have been any
significant
recent developments, or if there is a place where such developments are
chronicled. If ruby is in need of a new virtual machine, why not base
it
on OCaml?

Ocaml has an immensely effecient virtual machine, and it also supports
generation of native binaries on many platforms. Additionally, it
provides
a top-level interactive shell, and many mechanisms that vastly simplify
language creation, including a very powerful native parsing system
based
on streams.

OCaml plays well with C, so using the OCaml virtual machine for Ruby
would
probably make it easy to embed it in C programs, and use external C
code
inside of it.

Ocaml also lets you do some really strange tricks that might give ruby
programmers more deployment options. I have seen OCaml parsers that
generate c/cpp ASTs, for instance, and I imagine that, using similar
methodology, it may eventually be possible to use an OCaml based ruby
parser to generate bytecode for java, parrot, and python VMs.

I think Matz is pretty much dead set on writing his own VM. He says,
though, that we are free to roll our own VMs for Parrot et al.

From the Rite wiki page:
"Parrot doesn't affect matz's plans at all: he will make his own VM
(Rite), which will be the reference implementation if Parrot is ever
able to run Ruby code and becomes more popular than Rite."

So, while it would certainly be a great idea to create support for
OCaml, it won't be the reference implementation.

If you would want to contribute to that sort of a project, you might
want to check out Cardinal (Parrot for Ruby) on RubyForge. The first
step, IIUC, will be parsing the ruby code. It will, I believe, support
pluggable emitters for bytecode, etc...

cheers,
--Mark
 
M

Mikael Brockman

Ryan Paul said:
I just finished reading about Rite (thx to Mark for bringing it to my
attention, btw!), and I was wondering if there have been any significant
recent developments, or if there is a place where such developments are
chronicled. If ruby is in need of a new virtual machine, why not base it
on OCaml?

OCaml's VM is very quick indeed. But it's quick for OCaml code, and
OCaml code is very different from Ruby code. Actually, I'd say they're
almost opposites. Ruby's extremely dynamic, and OCaml's extremely
static. Ruby lets you reify the current continuation. ocaml has no
support for that, so you'd have to either (1) rewrite the Ruby code in
continuation-passing style, (2) ditch the ocaml stack and put everything
on the garbage-collected heap, or (3) hack the C code to copy the
stack. And so on. In my infinite wisdom, I predict that implementing
Ruby atop the OCaml VM would be very close to implementing a new Ruby VM
atop the OCaml VM.

Besides, most of the magic is in the compiler, anyways. The OCaml VM is
pretty straight-forward, I seem to recall. But the compiler, oh yeah!
OCaml is much easier to optimize than Ruby, but ocamlc is still really
impressive.

And compared to the byte-code compiler, virtual machines are easy to
write. If you haven't done so, matz, you should probably take a look at
the design of OCaml's VM; there are probably good ideas to be stolen.
But I doubt it'd be good to actually _use_ it.

Of course, I'm probably missing something, or plain out wrong.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top