[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: J2ME Implementation of Lua?
- From: ramsdell@... (John D. Ramsdell)
- Date: 09 Apr 2008 07:29:53 -0400
> David Given <dg@cowlark.com> wrote:
> It's a paper on bytecode translation of Lua onto CLR. If CLR can do
> it, I don't see any reason why the JVM can't; the two are
> architecturally very similar.
The CLR was designed to support a diverse set of languages while the
JVM is very Java specific. In particular, it's a pain to generate
Java bytecodes for languages that promise to implement some function
calls as tail calls, such as Lua and Scheme. The CLR has an
instruction just for this purpose. So just because the CLR can do it,
you should not assume the JVM can.
Quite a while ago, Jeff Siskind and friends translated a large Scheme
program that implemented a early silicon compiler into the native
language of the Symbolics Lisp Machine. This dialect of Lisp was not
tail recursive, and the result was huge runtime stacks. Besides being
a performance hit, it turned out the large stacks tickled a GC bug
that mysteriously crashed our machines. Imagine the fun we had
debugging that problem!
When translating Lua to Java bytecode, keep in mind the programmers
that take care to ensure some calls will be recognized as tail calls
by the Lua interpreter. Good performance of those programs may depend
on a faithful translation.
John