Go to Post As JFK said we did not do this because it was easy, we did it because it was hard. - Glenn [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Spotlight this post!  
Unread 09-06-2009, 07:23
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Learning to Program in Java

Quote:
Originally Posted by ExarKun666 View Post
I came across a weird thought in this process. One of my teachers, who teaches C++ and Java, told me that when you program and compile Java Code [not to robot, but for animation for example], and when you compile C++ [not to robot, but for animation for example], and you execute them both, and if they did the same thing, all same except the syntax of course, that C++ does the compiling and executing a little faster then Java. First of all is this true for the robot, and if it is, what possible effects could it have?
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.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Canera Calibration- Java program itsme Programming 1 20-01-2007 16:14
Robocode: Learning JAVA the fun way. While fighting with robots. Denalin Fusion Chit-Chat 2 26-09-2005 23:22
java to pbasic nzj1 Programming 11 09-01-2003 19:24
Java Books Yan Wang Programming 1 27-12-2002 16:26
No Java for XP Kyle Fenton Chit-Chat 21 23-07-2001 20:15


All times are GMT -5. The time now is 11:00.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi