rokdcasbah posted on May 19 2006 at 12:35 PM said:
yeah i learned a little java and at first i was interested in figuring out a way to get something running on the gp2x, but then i realized:
java is ass slow!
to sum it up:
- lots of (dynamic) casts in java.
- all objects, regardless of size, go on the heap.
- automatic garbage collection
- garbage collection plus larger heap = more memory used and possible use of virtual memory
perhaps once it's made open source we'll see some more different implementations.
While many of these points are true in general, there are ways to work around each one. One could argue that then you'd be defeating the purpose of using Java at all, which is probably a valid point. Some of the reasons why I use Java is because:
1) Great IDE's 2) Great analysis 3) multi-platform 4) Easier debugging 5) Simple language 6) language protection features like type safety and bounds checking really expedites development.
Some potential work arounds on above points:
- dynamic casts. well, just don't cast. And don't use any libraries that is based on runtime dynamic types. Or you can use lots of static methods/functions.
- objects go on the heap/garbage collection. Nothing inherently wrong with the heap. The problem is more like the garbage collector can slow you down at bad/all times. Well, just allocate everything at the beginning and don't dynamically allocate anymore.
Other issues not mentioned.
- array bounds checking. well, don't use arrays, at least not java arrays. :lol:
- slow startup. well, you can use GCJ. it will help startup time a bit. Not as long as JVM init time.
- No JIT for arm that I'm aware of. The blackdown SDK I found for arm doesn't seem to work right.
If you write some mathematically intensive apps in Java, you'll find that they run quite nicely compared to C++. Some Java progs may even run faster (although that seems unlikely). The only rationale for that is perhaps the JIT is doing a better job of optimization to native code than say GCC/G++ at compile time. This makes sense since the JVM knows more about performance statistics at run time than static compilers at compile time. (Although you can work around this too with GCC using profiling)
Sorry about the rant, but I think that Java is not all bad, even for mobile/embedded programming.