Welcome, Guest. Please login or register.

Author Topic: Java (sort of) for the Amiga  (Read 1684 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Java (sort of) for the Amiga
« on: December 18, 2006, 05:20:50 PM »
I'm just thinking out loud here... and forgive me if this topic has already been broached.

I know, of course, that there have been several (failed) attempts to port Java to the Amiga, primarily centered around the JVM. To the best of my knowledge, the majority (if not all) of these projects have been abandoned, I'm presuming, because of time issues, the Amiga's unfortunately underpowered CPU, and out of date libraries.

But has anyone considered the possibility of simply creating C++ libraries that mirror Java packages? In other words, mirror Java include files as C++ header files so that one may implement Objects or Swing or what-not in C++. One would implement this entire scheme by starting off with Java.Lang.Object, from which everything else is built, and expand from there.

Obviously, it would not be as simple as doing just that. I assume C++ datatypes would need to be mirrored as Java datatypes, programmers would have to discipline themselves not to use pointers, base libraries modified to conform to the Java standard, some effort would be needed to convert from a Java program to C++ and so on... but by eliminating the JVM, while you might loose the WORA paradigm, you still might gain a huge collection of apps.

Further benefits would allow the full power of whatever CPU the machine was running on. AROS, MorphOS and, even OS 4.0 might benefit too, if they never obtain a JVM.

I'm not expert, on Java, C++, or even the Amiga and I'm curious to hear other people's points of view on the subject. Such a project seems possible to me, albeit a large one.

But, like I said before, I'm just thinking out loud.

One thing is for certain, the Amiga still survives, if only in emulation, so... here's yet another way to keep it going. ;-)

Ed.
Ed.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Java (sort of) for the Amiga
« Reply #1 on: December 18, 2006, 06:11:24 PM »
I have a pet C++ framework that gives a lot useful classes (provided you want to do game/graphics type stuff, play with threads etc) but nothing like the featureset offered by java's runtime.

The problem you have is that java has a fair few syntatical differences from C++ that would make any such project impossible as well as keywords and their expected behaviours. There's no final, abstract, synchronized, implements, interface, import, export, extends etc and even though the behaviour of these can often be implemented, you won't get that implementation into a simple #define'd keyword that makes your source appear similar to the equivalent java source.

Furthermore, java uses garbage collection, C++ doesn't and writing a GC implementation on a system where your classes might have to do low level work (eg locking hardware resources etc), GC becomes extremely tricky to implement.

There are a great many more differences too, far to many to detail here.
int p; // A
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Java (sort of) for the Amiga
« Reply #2 on: December 19, 2006, 03:29:42 PM »
Not to argue with you, Karlos, but I don't see that as an issue. There are serveral Java to C++ translators that I'm aware of. How good they are, is another matter.

Here are some of the ones I'm refering too:
* Octopus - Java to C++.
* ANTLR - Java to C++.
* XES - Java to C++

I tried the first one. I didn't compile and run it, merely had it translate Java to C++, and it looks like it did OK.

As to garbage collection, that's a good point, but I get the impression that the tranlators above manage that. I could very well be wrong on that one, however.

I have no idea if this would be an easy task, but, then, that's why I'm "thinking out loud here." :-)

Ed.
Ed.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Java (sort of) for the Amiga
« Reply #3 on: December 19, 2006, 04:09:56 PM »
Source code translation is a different matter. What you initially suggested sounded more like making C++ syntactically more java like so that java sources could be compiled by C++.

Try converting Java to C++ that makes extensive use of threads, synchronized calls, static code within classes, anonymous closures, even without using anything beyond java.lang and you will run into problems.
int p; // A
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Java (sort of) for the Amiga
« Reply #4 on: December 19, 2006, 04:51:29 PM »
Syntacticly like Java? No. :-) Structurally like Java? So that one can use all the same libraries and methods? Yea, sort of... What I was thinking of was more a case of making the libraries look more like Java import libraries. But, to be honest, that's why I keep repeating "I'm just thinking out loud here" 'cause, I'm just trying to get my brain around the issue.

Your input's been quite helpful. Thanks. :-)

Ed.
Ed.
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: Java (sort of) for the Amiga
« Reply #5 on: December 19, 2006, 10:13:10 PM »
I'm not sure if GNU Classpath is written in C++ or Java but it's sure to make extensive use of the C++ Standard Template Library if it is written in C++.  I think that's only been semi-completely ported to the AmigaOS 4.0 version of GCC and available for AROS also, but not for the AmigaOS 3.x versions of GCC.

C++ is slightly more powerful than Java but it still doesn't have much for safety nets.  Java is much easier to learn because it does have garbage collection and so on.  It's just slower than C++ generally.  Also check out GCJ for a Java frontend to GCC.
 

Offline CrazyProg

  • Newbie
  • *
  • Join Date: Oct 2004
  • Posts: 14
    • Show only replies by CrazyProg
Re: Java (sort of) for the Amiga
« Reply #6 on: December 19, 2006, 11:22:34 PM »
I do not know Java or C++ (I do know C though), how about approching this from a different point.  Instead of writing C++ like Java, how about writing a Java to C++ preprocessor.

To work it
  1) write your Java code
  2) run though a preproccessor
  3) compile the code generated
  4) run the generated executable.

The preproccessor can add in all the stuff needed to do the garbage collection etc. this way you are still writing Java, you can make any C++ helper libraries you need any way you feel like as only the preproccessor needs to know how to use them.  You might be able to get external Java extensions to work as long as they are pure Java.

You could probably make this all one step too, by getting the preproccessor to run the compiller internally.
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Java (sort of) for the Amiga
« Reply #7 on: December 20, 2006, 12:30:59 AM »
Quote
CrazyProg wrote
I do not know Java or C++ (I do know C though), how about approching this from a different point.  Instead of writing C++ like Java, how about writing a Java to C++ preprocessor.

The work you need to do amounts to creating the entire Java-environment, minus the bytecode interpreter and JIC-system. In other words, if you can do that, you can add those little things too. Computer languages are no longer just a set of keywords you compile into native assembly language; they are a complete set of libraries, runtime systems, extensions, and lots more.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: Java (sort of) for the Amiga
« Reply #8 on: December 20, 2006, 02:15:56 AM »
@CrazyProg

I think that's how GCJ works.  See the link in the last sentence of my previous post.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Java (sort of) for the Amiga
« Reply #9 on: December 20, 2006, 07:52:07 AM »
@SamuraiCrow
Quote
but it's sure to make extensive use of the C++ Standard Template Library if it is written in C++. I think that's only been semi-completely ported to the AmigaOS 4.0 version of GCC and available for AROS also, but not for the AmigaOS 3.x versions of GCC.

STL is fully portable (there is no need to "port" it), and it builds out of the box. It's available in all GCC variants, including AmigaOS 3.x m68k.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Java (sort of) for the Amiga
« Reply #10 on: December 20, 2006, 07:58:54 PM »
Yes, as I understand it, GCJ compiles Java directly. You would still need the Java libraries, I presume, and you'd still have to compile the low-level libraries for the OS. But I could be talking out my S here. :-)
Ed.