
09-06-2009, 18:07
|
 |
Ben Error/MC Ben/NC Ben
AKA: Ben Kellogg
 FRC #2429 (LCEC)
Team Role: Programmer
|
|
Join Date: Dec 2007
Rookie Year: 2008
Location: La Caņada, CA
Posts: 208
|
|
|
Re: Learning to Program in Java
Quote:
Originally Posted by Jared341
In general, C++ is faster. This is because C++ gets compiled into native machine code that can be directly executed by your processor. Java, on the other hand, gets compiled into an intermediate representation called byte code. The byte code is portable across all sorts of operating systems and processor types, but it must be interpreted into machine code at run time in order to execute. It is this interpretation step that generally makes Java run slower (although sometimes it can actually be a benefit with JIT compilation, but that's another issue). However, the Java Virtual Machine is constantly being improved and this performance gap is much smaller than it once was.
One other factor that has traditionally scared roboticists away from Java is garbage collection. In C/C++, memory is allocated and freed by the programmer directly. In Java, memory is periodically freed when needed (a process called garbage collection). While this makes a programmer's life much, much easier, it means that sometimes the system will decide to do garbage collection at an inopportune time, causing you to miss real time deadlines. However, once again there has been some advancement in this area that has turned this issue from show stopper to mere nuisance.
I don't think we'll see an enormous performance difference between Java and C++ on our cRIOs. Besides, most teams are only scratching the surface of what the cRIO can do. And good Java is both more robust and oftentimes faster than bad C++ - if a team isn't comfortable with C++, any code that they produce may well end up being faster in their Java implementation anyways.
|
So out of the languages allowed: C/C++, LabVIEW, and Java, there is not a real big difference that would effect the performance of the cRIO, or robot operations?
|