Re: Euphoria/Java
- Posted by David Cuny <dcuny at LANSET.COM> May 15, 2000
- 649 views
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