View Single Post
  #11   Spotlight this post!  
Unread 09-06-2009, 18:07
ExarKun666's Avatar
ExarKun666 ExarKun666 is offline
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
ExarKun666 is an unknown quantity at this point
Send a message via AIM to ExarKun666 Send a message via MSN to ExarKun666 Send a message via Yahoo to ExarKun666
Re: Learning to Program in Java

Quote:
Originally Posted by Jared341 View Post
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?
__________________
Ben Kellogg




Team Sites: [LCEC Site] [FRC/FLL Site] [LCEC Blog]
Reply With Quote