1. Euphoria/Java

Since it can finally more or less run the queens.ex demo, I've decided that
it's time to announce my latest and greatest project: a Euphoria to Java
translator. As usual, it's pre-pre alpha, capable of only working with toy
programs. You can download it from:

    http://www.lanset.com/dcuny/java.htm

As implemented, the generated code is very sluggish. The reasons for it
are... well, suffice it to say that there are a lot of things in the code
that are being rewritten. Only a very small handful of library routines are
coded, and in the case of some (clear_screen/get_key), they are merely
stubs.

As the included test.ex demo shows off, it's possible to implement
routine_id/call_proc. Adding AWT or Swing should result in a cross-platform
GUI version of Euphoria, which is the whole point of this exercise.

As usual, feedback is appreciated.

-- David Cuny

new topic     » topic index » view message » categorize

2. Re: Euphoria/Java

On Wed, 10 May 2000 18:29:56 -0700 David Cuny <dcuny at LANSET.COM> writes:

>it's time to announce my latest and greatest project: a Euphoria to
>Java translator.

Tres cool!

>suffice it to say that there are a lot of things in the
>code that are being rewritten.

The lexical analyzer?

> Adding AWT or Swing should result in a cross-platform
>GUI version of Euphoria, which is the whole point of this exercise.

Very clever!

>As usual, feedback is appreciated.

Since I'm working on a similar project, I read your code
with great interest. If my understanding is correct,
you are writing the Euphoria evaluator in Euphoria, and
emitting Java code.  You state that speed is
an issue, so wouldn't it make more sense to write the
Euphoria interpreter in C, and emit Java code, or Java bytecode?

I'm new to both Java and Euphoria, so I'm probably just
emitting nonsense.

Please keep us informed as to the progress of the
Eu/Java translator.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Euphoria/Java

R. W. D. wrote:

>>suffice it to say that there are a lot of things in the
>>code that are being rewritten.
>
> The lexical analyzer?

i'm tracking more information about token type and scope. the big rewrite
takes place on the java code side - a better sequence class, more
conservative use of cloning, addition of string and numeric literals, and
perhaps even support for native java types.


> > Adding AWT or Swing should result in a cross-platform
> >GUI version of Euphoria, which is the whole point of this exercise.
>
> Very clever!

it looks quite feasible, but it's not working yet. the AWT is a fairly close
mapping to Win32Lib, both in controls, events and API calls. i know AWT is
deprecated, but i don't have a current version of java on my machine. and
converting AWT code to Swing is supposed to be fairly straightforward.


> Since I'm working on a similar project, I read your code
> with great interest. If my understanding is correct,
> you are writing the Euphoria evaluator in Euphoria, and
> emitting Java code.

entirely correct.

what sort of project are you doing, and could you supply some information
about it?


> You state that speed is an issue, so wouldn't it
> make more sense to write the Euphoria interpreter
> in C, and emit Java code, or Java bytecode?

the speed of the generated java code is the issue. it's about 10 times
slower than euphoria, although my vm is old, so it's probably not as bad as
that.

i suspect that i could get an appreciable speed increase by supporting
native java int and float. currently, there is only one data type: the
object. unfortunately, this gets really complex on the code generation side.
and i need a zillion versions of core routines, like:

   compare( int, int)
   compare( int, float )
   compare( int, Seq )
   compare( int, Obj )
   compare( float, int)
   compare( float, float )
   compare( float, Seq )
   compare( float, Obj )
   compare( Seq, int)
   compare( Seq, float )
   compare( Seq, Seq )
   compare( Seq, Obj )
   compare( Obj, int)
   compare( Obj, float )
   compare( Obj, Seq )
   compare( Obj, Obj )

if i use native types, instead of casting everything into an Object
(actually, the Eu class).

i don't plan on getting involved with java bytecode unless i really have to.
it would make more sense if i was writing an interpreter instead of a
translator. but i'd probably not resort to that immediately, either. coding
a jumptable would certainly make running euphoria bytecodes a lot more
efficient. i've got the o'reilly 'java virtual machine' book ($4 on sale!),
and i'm slowly making my way through it. i ran across another java vm book
that discusses implementing other languages, but i don't have $40 in spare
change to shell out.

besides, there's a world of difference between translating euphoria into
java, and writing a euphoria interpreter in java. i only wish i had the
spare time to work on that type of project.


> Please keep us informed as to the progress of the
> Eu/Java translator.

at the moment, i'm concentration on getting Win32Lib emulation working. i'm
aiming more for a proof of concept than anything else. i'd like to get
something out soon, but this coming week is *very* busy. we'll see.

i'm working on two different versions. the first version implements native
data types, and should ultimately run much faster than the current version.
since it's a lot more complex, i may not go that route unless test show
generated code is *much* faster.

the second version is the posted code with hacked code optimizations. it has
much more conservative cloning of sequences, string/numeric literals, and
more efficient construction of expressions using the concatonation operator.
all this work resulted in a disheartening speedup of only about .5 seconds
from a 28 second total.

i obviously don't have a really good grasp of what operations are the most
expensive, and how to optimize them. in the future, i'm going to do tests to
ensure that optimizations really do speed up code before coding them.

thanks for the feedback!

-- david cuny

new topic     » goto parent     » topic index » view message » categorize

4. Euphoria/Java

I've posted a minor update to my Euphoria/Java program, at:

   http://www.lanset.com/dcuny/java.htm

The changes create slightly faster code.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Euphoria/Java

The latest pre-alpha of Euphoria/Java is available at:

   http://www.lanset.com/dcuny/java.htm

It's got more core functions, and I've added the sieve demo.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu