Why can't I run Java anywhere yet?

Armed with GNU compilers, I can write C (or even C++ or Obj-C) code that I can get to run on pretty much any device in existence (admittedly with a degree of hair loss, rage, and sleepless nights). My code, though fiddly and ugly, will run anywhere.

Armed with Java SE, I am entirely restricted as to where I can deploy my bytecode by the availability of a VM for the target device. As of today the only useful places I can deploy my code are the Windows and Linux desktops. Even Mac is a second class citizen because I am at the mercy of Apple, who decide what Java code I can and can’t run.

I want to know why there is no universal runtime platform for Java, with fairly universally reliable characteristics, available in a whole bunch of handy prebuilt C libraries or in source form for those more esoteric platforms, like there was always meant to be. It’s been 15 years - this is crunch time for Java now. If we don’t see it on the consoles, iPhone and iPad in short order, it’s never going to happen.

Cas :slight_smile:

Sort of a tangent to the original thread, how starting a new one?

Kev

[quote=“gouessej,post:30,topic:34858”]
I was under the impression Google used Dalvik because J2ME didn’t meet their needs (and it being quite comprehensively **** didn’t help either)

there is also now the zero project http://openjdk.java.net/projects/zero/

You can pretty much use that to build a vm for any platform (where you can compile code on). Following that just run your java code with it :slight_smile:

Well-written C which doesn’t make assumptions about things like byte ordering, uses appropriate typedefs for primitive types, is conservative in the use of structs, and depends on no libraries or on open source libraries which meet all the above criteria, can be compiled and run correctly on many platforms. Note the number of qualifications already. When you then take into account the crazy variety of platforms that are out there - 7-bit bytes in some architectures, 35-bit words in others, etc - “anywhere” seems to be rather overstating the case.

::slight_smile: Maybe it could work on some ADSL boxes. Does it require OpenGL support?

All platforms and devices, yes that’s an overstatement. But Windows, Mac and Linux support should all be pretty much unified by now.

I’m not saying that the same source code should run anywhere. In fact that’s the totally naive view of the people who bought into that genius bit of marketing bullshit “write once run anywhere”. It’s a total fallacy. The same source code doesn’t even run the same between Windows and Mac OS, let alone between iPhone and XBox.

What I am saying is that wherever there is a CPU and some memory, I can write and deploy C code to it and it will run. This is not the case with Java. I am reliant on a JVM, and to date, JVMs have been exceedingly hard to come by. The only worthwhile JVM is the Sun Hotspot JVM, and that’s only available on Windows and Linux with an irritating license forbidding customisation. I can’t choose the JVM I deploy to on Mac OS. My bytecode is worthless on iPhone and iPad and XBox and Playstation. I have no option but to port the whole sodding lot to C (or C++ maybe), in which case, why did I bother with Java in the first place?

Cas :slight_smile:

Zero - a small movement in the right direction but notably lacking in the console / Applification department, focused on Linux as usual, which is all very good for the soul and extremely poor for the wallet. Will it be fast enough for games? Doubt it if it’s based on LLVM. Perhaps what’s needed is some bright spark to create an instruction-tracing JIT for the JVM - much simpler than Hotspot and almost as fast, as I understand it.

Cas :slight_smile:

I hear ya Cas. This is why I started my experiment a few months ago to try and move over to C++. I have to admit though, it’s been more difficult than I had originally supposed.

C++ was fine until I started using libraries (openGL, sound, input). Even when using an already built game engine (like Ogre), I was still running into major roadblocks for cross-platform compatibility. The libraries would only be available for one, maybe two platforms at most (usually just windows), and even when available, still required different code sets. I even ran into problems trying to use Eclipse on each platform (I wanted a single IDE), and had to start learning Microsoft’s Visual tools, Mac’s XCode, etc… I think this is why most C++ games are built with a single platform in mind.

As I moved into checking out the iPhone (or iPad) for development, I learned that to really develop for it meant I’d also need to learn Objective-C, and maintain yet another codebase.

To compile my code for each platform meant needing to have that platform available. This might be doable with some good VM software, but it was still a pain.

Furthermore, the lack of garbage collection just seemed archaic to me. Yes, it’s nice to have total control at times in order to keep the speed of the game at max, but even the AAA titles out there fall apart at the seams with memory leaks. I’ve heard that there’s some C++ libraries out there that implement GC, but yet again, there’s another library to find and compile for each platform. iPhone doesn’t even support the Objective-C GC btw.

In the end, I came back to Java. Running back to Java? No. With my shoulders hung a bit low? Yep. My advice is that if you want to move to C++, stick with Windows and learn the DirectX libraries. Maybe pick up one mobile device, like the iPhone, and stop at that. I’m excited about the Android platform, as it’s all Java. And I’m excited about Oracle’s unification plans for Java (although I’m skeptical).

I could probably write an entire dissertation on my experience, but I’ll spare you. C++ isn’t the greener grass on the other side though. Maybe in the future, something like Google’s Go might succeed, or Oracle will get a clue and build a Java-to-machine-code compiler option. C# and Mono look like an interesting possibility, but currently lack the game libraries that Java has (I REALLY appreciate LWJGL now). And now that Google and Motorola have decided to enable multitouch on their Android phones, I’m more interested in their mobile tech over the iPhone’s anyway.

I hope this helped in some way.

What’s the status of GCJ these days? Any more useful?
What about JET? Does it/will it target more platforms?

Last time I talked to Dmitri Leskov of Excelsior, JET was basically Windows or Linux, and there wasn’t the money to do a Mac port or XBox or Playstation, which is a massive shame. I’m wondering if Oracle might help out here.

Cas :slight_smile:

The basic idea behind zero is to kill all CPU specific code in the JVM tree (means zero assembler) to make the source more portable and easier to maintain. Add Shark (the LLVM portion) to generate native code. LLVM is designed for lifetime & whole program compiling and ‘should’ be vastly superior to tracing JITs. LLVM is starting to spread: Apple’s GCC & OpenGL and pretty much all OpenCL vendors. I don’t see a strong linux focus (other than redhat is pick-up the bill) on Shark/Zero and likewise for Apple & LLVM.

WRT Dalvik - register based VMs require 20% less instructions on average, so it helps with the memory footprint.

I understand your original point, I’ve always found it easy to write portable C. But as a devil’s advocate, the stuff that’s portable iffy in Java is likewise in C, no?

GCJ is considerbly better now. Pretty usable. Though still gonna give you cross platform issues.

IPhone-wise the XMLVM team have been working really really hard. It’s performance and capabilities are progressing very quickly. As to not being able to get any Java games on the Apple AppStore - I have 3 currently.

Kev

I’m still pretty miffed at their approach though. Their website makes all kinds of bold claims about transforming between language but the only transformation path that actually works is Java -> iPhone. They’d get a lot more respect if they were up front about it and said that was their actual focus rather than pretending that the other backends (ie. C#) were fully functioning when they’re flat out broken.

IMO, the major problem with Java is that there was bad choice of merging too much API and JVM into something called JRE…

If you write Java pure code it will run fine and the same (nearly) everywhere (thats also why I am affraid when they claim to add “closure” and such while Java is not yet stabilized…), but as soon as you start using JRE-API you get into trouble of versioning and bugs of the JRE.

Without all those very target-specific JRE-API, building a JVM for a new device (as building a C compiler) should not be that hard (because it is basically the same to do).

C is just Everywhere, back years ago… I had to built and program a DSP box using TMS320XXX, and guess what was the possible languages with the provided constructor tools ? ASM & C … “after the Assembly” C is probably the first compiler made for a new device.

EDIT : in contradiction with what I said above about JVM :P… it is probably related to the simplicity and its machine similarity for the whole language : implements while/for/if/switch/expression => C compiler is nearly finished.

Orange has just chosen GameTree tv for its ADSL boxes, it relies on C++ :’( Java has lost the fight once more. Oracle, please do something!!!

What we need is something like what Lua has - just a crossplatform shared library (with various other files for runtime classes etc) that you can call into from C. And an absolutely 100% liberal license.

Cas :slight_smile:

Isn’t all the Swing and AWT stuff still missing? Plus Wikipedia says the project is practically dead now.