I love java. it is a nice high level programming language and the way the VM works is both cool and great. But java is a slow language and I don’t know about other teams but optimization was an issue for us this year. I see that the java library for FIRST uses a light weight JVM my question is does anybody know whether or not this will be close enough to as fast as C++ to make programming in java worth it?
the Squawk Java virtual machine was developed at Sun Microsystems labs specifically for use in embedded platforms, and having used it on arm platforms, I must say it runs particularly fast–comparable to writing C++ for the same platforms. This is the case in part because Squawk runs “on the metal”, ie without a host operating system to create overhead or incur performance costs. On many platforms, java now runs as fast or faster than C/C++, except when OS-Related I/O functions are called, tending to be the biggest bottleneck. On the metal, this is a non-issue, and the Java interpreter has been really well optimized. Finally, I’d point out that Java’s garbage collector is rather nice…
In terms of library support, it is currently looking like the Java abstractions provided by WPI/Sun for robot hardware are rather nice… http://livemyst.comli.com/wpilibj/doc/index.html shows that most robot hardware can be dealt with cleanly through object methods.
There is nothing to say that C++ or Java is bad or should be avoided, its really more of a preference call, not performance.
I can’t say anything about SJVM, but from what I’ve noticed and timed on my own computers, java is slower to load, but once it’s loaded, it’s slightly faster that C/C++. I’m not going to worry too much about the performance of Java on the cRio. Like alivemyst said, It’s personal preference as to which one you use.
What were you doing that made optimization an issue?
About the only thing that FIRST robots can do that will seriously tax a micro controller is image processing…but the NI vision libraries are highly optimized native code. Whether from LabView, C++, or Java, a call to an NI vision function takes the same amount of time.