Page 1 of 1

cross compilation & java bytecode

Posted: Wed Apr 07, 2004 12:38 am
by DoubleDutch
I mentioned previously that cross compilation to one of the other versions of purebasic would be great, i.e compile an amiga or linux program in the microsoft version. etc

But also a version that will compile to Java Bytecode would be GREAT!!!

This would allow PureBasic programs to run on almost any system. Of course only a subset of the commands would work, but it would still be good.

Posted: Wed Apr 07, 2004 8:51 am
by Froggerprogger
Yes, that would be wonderful !

[In fact I sometimes used PB together with Java: in the way calling PB-DLL-functions as native Java-functions and for the actual project I write the GUI in PB and let Java do some calculation (because of full doubles & int64 support - and it is possible to encapsulate the java-part to let it run on all machines at the university - via SSH :) )]

Perhaps it would be the easiest way to write a sourcecode-parser that 'simply' translates your PB-code to Java-source and then compile that to bytecode using an installed java-compiler. This should give no problems with all datatypes, maths, arrays, linked lists, loops, ifs, procedures, and perhaps even the window-lib (perhaps - I never used e.g. swing yet) and some others (file, network,...) etc.

But there will exist problems with the 3D-engine and the main limitation that Java doesn't support pointers of any kind. So you cannot directly address the memory (for Peek/Poke/@/? and all this stuff). This is all done by Java Runtime itself (and seems to be necessary for this huge crossplatform-compatibility) But perhaps you could make a workaround using bytearrays for this.

OK - Fred ? Do you think this is possible for you until May ? pleeease :D

Posted: Wed Apr 07, 2004 9:14 am
by KarLKoX
yes, it would be an excellent feature to let purebasic to be more and more popular but this is a very BIG task.
Perhaps for pb 6.0 or 7.0 :roll:

Posted: Wed Apr 07, 2004 10:32 am
by freak
If you want Java Bytecode, why don't you use... Java? :P

Posted: Wed Apr 07, 2004 11:46 am
by techjunkie
freak wrote:If you want Java Bytecode, why don't you use... Java? :P
Yeah - I agree... Java would only be a very small part of PB with it's limitation and so on - and lets face it Java is JAVA, Pure Basic is BASIC... It really doesn't "fit" in the Pure Basic concept and for example... What GUI should you use? Swing classes? Should it support Java 2? Applets or only native Java code?

Better with a Pure Basic plug-in in that case... as Clickteam have done with Jamagic.

That's my opinion... :roll:

Posted: Wed Apr 07, 2004 7:16 pm
by DoubleDutch
I don't know if I was being clear enough...

I mean compile to the virtual machine bytecode, not to the java language. Its the bytecode thats interpreted, not the Java source. Thus to Fred its just another machine to compile to, like the 68k or others.

This way the resultant file will run on any system that has implemented a Java interpreter.

In any event, even if you think that "JavaByteCode" output is a long way off, possibly cross compilation between the 2 x86 BASIC versions (Linux and Microsoft) isn't?

What do you reckon Fred?

Posted: Wed Apr 07, 2004 9:31 pm
by techjunkie
DoubleDutch wrote:I mean compile to the virtual machine bytecode, not to the java language. Its the bytecode thats interpreted, not the Java source. Thus to Fred its just another machine to compile to, like the 68k or others.
Yes - but you still will be stuck with the limitations (and speed) of Java... and need all the Sun JRE-stuff... and I don't see the point really - of the 660 Pure Basic command, you maybe can use 100 - 200 for use in Java bytecode (at most)... (my guess - can be totally wrong)

No DirectX access, no access to hardware, no access to the filesystem (if you run it as an applet), different GUI - you have to remake PB totally...

To generate Java bytecode, isn't the same as for example generate XBox binaries. There you have the same foundation and can use the same dll's.

I CAN see the point if you wanna do a simple 2D game in Pure and then generate Java bytecode, so you can run it on different platforms - it's the only use I can see... and the most easy implementation... That would be pretty cool...

If you wanna use GUI and so on... GOD, what a workload for Fred... *L*

Why not generate code that you can run with MS .NET Framework to begin with? :-)

Posted: Thu Apr 08, 2004 1:18 pm
by techjunkie
techjunkie wrote:Why not generate code that you can run with MS .NET Framework to begin with? :-)
For the record: I hate :twisted: MS .NET Framework... :twisted:

:lol:

Posted: Thu Apr 08, 2004 10:17 pm
by Shannara
Same here, why generate scripts when you can generate real code?