|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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? |
|
#3
|
|||||
|
|||||
|
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!). |
|
#4
|
|||
|
|||
|
Re: C++ vs. Java Performance
2) Interesting...On the USFIRST.org beta testing forums, team 67 posted this:
Quote:
...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 |
|
#5
|
|||
|
|||
|
Re: C++ vs. Java Performance
Quote:
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. |
|
#6
|
|||||
|
|||||
|
Re: C++ vs. Java Performance
Quote:
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 : 11-15-2009 at 07:37 PM. |
|
#7
|
|||
|
|||
|
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.
|
|
#8
|
|||
|
|||
|
Re: C++ vs. Java Performance
Quote:
Quote:
Quote:
|
|
#9
|
||||
|
||||
|
Re: C++ vs. Java Performance
Where can I download it?
|
|
#10
|
||||
|
||||
|
Re: C++ vs. Java Performance
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION*** | Pjohn1959 | Programming | 37 | 08-31-2009 03:55 PM |
| Image processing and performance | ellisk | C/C++ | 6 | 01-20-2009 04:48 PM |
| AndyMark Performance Wheels | ChuckDickerson | Technical Discussion | 49 | 12-27-2006 06:49 PM |
| Globe Motor - Performance at Cursor | Katie Reynolds | Motors | 1 | 01-19-2006 08:48 PM |