Go to Post I feel like I need to rinse out my brain with drain cleaner - dlavery [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

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 14-11-2009, 21:06
manderson5192 manderson5192 is offline
Registered User
AKA: Matt Anderson
FRC #0948 (Newport Robotics Group: NRG (pronounced eNeRGy))
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Bellevue, WA
Posts: 62
manderson5192 is on a distinguished road
C++ vs. Java Performance

Hey guys,

My team is having difficulties choosing between C++ and java this year. Here are the considerations we need help with:

1) Ease of use / code complexity / framework: We have a large group of qualified programmers (about 10 people). Two of us are veterans from last year who used C++ but are highly competent in Java (5's on the AP Computer Science AB exam last year). The rest are all either proficient or approaching proficiency in Java. I've heard that the java code is a whole lot cleaner and easier to use than C++. Can somebody confirm this (preferably beta-testers, not random speculators. I already know the general ideas one can get from google).

2) Code execution speed: Obviously, java will be slower than C++. Can somebody do some timing tests to find out what the slowdown factor *actually* is? In your experience, does the slowdown make a difference (in your present application)? Do you think it will make a big difference during build season?

3) Ease of parallelism: Multi-threading on C++ last year was a PAIN. I know multithreading is generally easier in Java...does this rule follow on the cRIO?

We could really go either way on this decision, but I, personally, would prefer to use java if there's no great cost to that decision.

Thanks guys!
-Matt Anderson
Reply With Quote
  #2   Spotlight this post!  
Unread 14-11-2009, 21:36
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: C++ vs. Java Performance

Adam Martin from Team 40 just gave a fantastic presentation at WPI about his experience in porting his 2009 C++ code to Java. I would defer to him on this decision, but I'll try to summarize his points briefly:

1) Porting the code was 90%+ copy paste find replace.
2) Even though he had a really awesome bot, he didn't hit performance bounds in either - he had sensor feedback on 9 of the 12 motors and several PID loops AND working vision tracking AND working vision assisted scoring in autonomous.
3) He claims to not be a programmer.


I don't have the link to his presentation, does anyone know where to find it?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-11-2009, 11:11
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: C++ vs. Java Performance

1) Java is definitely easier to pick up from scratch than C++, and I would argue that it is easier for C++ programmers to pick up Java than visa versa. As for the code being "clean", that is a matter of preference, but I would tend to agree that Java looks cleaner to me (for example, all objects are passed by reference implicitly whereas in C++ you specify explicitly whether to pass by value, reference, const reference, pointer, const pointer...).

2) Like Eric said, I don't think any of the beta testing teams observed Java to be any slower than C++ (and the only truly taxing processing that FIRST robots do - computer vision - is outsourced to NI's vision library which is written in native C).

3) Again, this is a preference thing, but I prefer the simplicity of threading in Java. On the FIRST Forums, I have posted Team 341's ported 2009 C++ code, and we use some threads in there (take a look!).
Reply With Quote
  #4   Spotlight this post!  
Unread 15-11-2009, 13:33
manderson5192 manderson5192 is offline
Registered User
AKA: Matt Anderson
FRC #0948 (Newport Robotics Group: NRG (pronounced eNeRGy))
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Bellevue, WA
Posts: 62
manderson5192 is on a distinguished road
Re: C++ vs. Java Performance

2) Interesting...On the USFIRST.org beta testing forums, team 67 posted this:

Quote:
the almost-empty loops we've timed run about 50 times faster in C++ than in Java.
Is there really no noticeable performance hit?

...and a couple, related question:

4) How does the Java vision API compare to the C++ one? Is there a large speed difference?

5) After having beta tested in java, will your team use it this year?

6) When do you think everything will be released for us non-beta-testers?

Thanks again!
-Matt
Reply With Quote
  #5   Spotlight this post!  
Unread 15-11-2009, 13:50
Abrakadabra Abrakadabra is offline
Here We Go !!!
AKA: Scott Kukshtel, Mr. K
FRC #3467 (The Windham Windup!)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2002
Location: Windham, New Hampshire
Posts: 160
Abrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant future
Re: C++ vs. Java Performance

Quote:
Originally Posted by manderson5192 View Post
2) Interesting...On the USFIRST.org beta testing forums, team 67 posted this:

"the almost-empty loops we've timed run about 50 times faster in C++ than in Java. "

Is there really no noticeable performance hit?

...and a couple, related question:

4) How does the Java vision API compare to the C++ one? Is there a large speed difference?
...
I'm not a Beta tester, but I did talk with Brad Miller (father of WPILib) at RiverRage, and he spoke to two of your questions:

Re: Performance - Yes, C++, which compiles down to native machine code is always going to be faster than Java in pure speed tests, because Java has to take the extra step through the virtual machine. However, for our application, most (if not all) of the time-critical pieces are done in the FPGA libraries, where the JVM isn't a factor.

Re: Vision libraries - the vision processing code remains in C++, and is accessed in Java via wrappers that use the JNI (Java Native Interface), so again, there is no Java performance penalty involved.

HTH.
Reply With Quote
  #6   Spotlight this post!  
Unread 15-11-2009, 17:47
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: C++ vs. Java Performance

Quote:
Originally Posted by manderson5192 View Post
2) Interesting...On the USFIRST.org beta testing forums, team 67 posted this:



Is there really no noticeable performance hit?

...and a couple, related question:

4) How does the Java vision API compare to the C++ one? Is there a large speed difference?

5) After having beta tested in java, will your team use it this year?

6) When do you think everything will be released for us non-beta-testers?

Thanks again!
-Matt
I would argue that an empty loop hardly makes for a meaningful speed test. But yes - perfectly written Java will almost always lose in a performance test against perfectly written C++. But to Java's credit, it is often easier to write good Java than it is to write good C++, which can tip the scales back in Java's favor. Regardless, FIRST robots really don't tend to do anything all that computationally complicated.

4) None at all as far as I can tell. It's the same code running underneath it all.

5) Definitely - it is much more accessible to our students than C++.

6) Not sure. "Soon" seems to be the general consensus. Definitely in advance of build season.

Last edited by Jared Russell : 15-11-2009 at 19:37.
Reply With Quote
  #7   Spotlight this post!  
Unread 15-11-2009, 19:15
manderson5192 manderson5192 is offline
Registered User
AKA: Matt Anderson
FRC #0948 (Newport Robotics Group: NRG (pronounced eNeRGy))
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Bellevue, WA
Posts: 62
manderson5192 is on a distinguished road
Re: C++ vs. Java Performance

Thanks for the help, guys! At this point, it sounds like team 948 will be going java as well =D.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-12-2009, 19:28
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: C++ vs. Java Performance

Quote:
Originally Posted by manderson5192 View Post
2) Interesting...On the USFIRST.org beta testing forums, team 67 posted this:

...and a couple, related question:

4) How does the Java vision API compare to the C++ one? Is there a large speed difference?
The Java vision stuff is actually written in C++ for high performance. In Java you refer to pointers to C++ image objects to make sure that there are no slowdowns due to any complex image processing that needs to get done.

Quote:
6) When do you think everything will be released for us non-beta-testers?
Yesterday
Quote:
Thanks again!
-Matt
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #9   Spotlight this post!  
Unread 05-12-2009, 18:18
Dragonos's Avatar
Dragonos Dragonos is offline
Web Master/ Engineer/ Programer
AKA: Eric G.
FRC #0095 (The Grasshoppers)
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Upper Valley NH
Posts: 16
Dragonos is an unknown quantity at this point
Re: C++ vs. Java Performance

Where can I download it?
__________________


PM me for 3dsMax Help!
Reply With Quote
  #10   Spotlight this post!  
Unread 05-12-2009, 20:01
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: C++ vs. Java Performance

See Bill's Blog for the release announcement:

http://frcdirector.blogspot.com/2009...ot-bill-2.html
Reply With Quote
Reply


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
**FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION*** Pjohn1959 Programming 37 31-08-2009 15:55
Image processing and performance ellisk C/C++ 6 20-01-2009 16:48
AndyMark Performance Wheels ChuckDickerson Technical Discussion 49 27-12-2006 18:49
Globe Motor - Performance at Cursor Katie Reynolds Motors 1 19-01-2006 20:48


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

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