Go to Post Don't worry about where you will be. Just consider youself lucky for being where you have been. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-09-2010, 18:59
dirienzo dirienzo is offline
Registered User
AKA: Nick DiRienzo
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2009
Location: USA
Posts: 15
dirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to behold
Java versus C++

Hey everyone. I'm fairly new to FRC programming (and programming in general, for that matter).

I am wondering if anyone has ran any benchmarks on robot code execution with Java and C/C++. Java compiles to bytecode which is then executed by the virtual machine at runtime, correct? While C/C++ compiles into machine code. Is there a noticeable performance difference between the two languages?

Also, when I uploaded code to the cRIO, I remember something about LabView in the console window. Was a LabView 'layer' created for communication with the hardware; what is going on there?

I am the lead developer for this season and our previous developers did not explain much. This past season was the first year using Java for our team, so I want to make an educated decision on language choice.

On the other hand, if there are no performance differences, it's just a syntax preference then.

Thanks,
Nick DiRienzo
  #2   Spotlight this post!  
Unread 21-09-2010, 19:37
GGCO's Avatar
GGCO GGCO is offline
Registered User
AKA: Grant
FRC #3357
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2004
Location: Michigan
Posts: 406
GGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to behold
Send a message via AIM to GGCO
Re: Java versus C++

My personal preference is Java. Our team has decided it's not only a great language to use/learn, but a much more marketable skill to advertise.

That being said, there are countless threads like yours on CD. A quick search would have revealed these (to name a few).

http://www.chiefdelphi.com/forums/showthread.php?t=86026&highlight=programming+langu ages

http://www.chiefdelphi.com/forums/showthread.php?t=85982&highlight=programming+langu ages
__________________
"Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein
The FIRST Alliance
COMETS Robotics
Website

  #3   Spotlight this post!  
Unread 21-09-2010, 19:45
gblake's Avatar
gblake gblake is offline
6th Gear Developer; Mentor
AKA: Blake Ross
no team (6th Gear)
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Virginia
Posts: 1,940
gblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond reputegblake has a reputation beyond repute
Re: Java versus C++

I too am interested in the replies you get, but...

If you are facing a learning curve because you aren't inheriting much experience from previous years' teams; I suspect that folks are going to emphasize that familiarity with the language you use far outweighs any speed differences.

Until you require the computer/software combination to do some complex operation(s) faster than the computer can execute your instructions in a "slow" language, you can ignore any speed differences (Yes - I know there are 2nd and 3rd order effects that can become important; but let's focus on the 1st order topic(s) before diving into the weeds).

To say it another way, the language's efficiency is sort of like a rope used to cross ditches. If you need to cross a collection of ditches and the widest of them requires a 10 foot rope; if you have a 15 foot rope, then you are in good shape. Having a 30 foot rope doesn't get you into any "better" shape.

I think you can guarantee that you are facing a learning curve. Do you also plan to cross any 20 foot ditches? If not, pick the language that is easiest to understand and easiest to use to get you across the metaphorical 10 foot ditches.

Blake
__________________
Blake Ross, For emailing me, in the verizon.net domain, I am blake
VRC Team Mentor, FTC volunteer, 5th Gear Developer, Husband, Father, Triangle Fraternity Alumnus (ky 76), U Ky BSEE, Tau Beta Pi, Eta Kappa Nu, Kentucky Colonel
Words/phrases I avoid: basis, mitigate, leveraging, transitioning, impact (instead of affect/effect), facilitate, programmatic, problematic, issue (instead of problem), latency (instead of delay), dependency (instead of prerequisite), connectivity, usage & utilize (instead of use), downed, functionality, functional, power on, descore, alumni (instead of alumnus/alumna), the enterprise, methodology, nomenclature, form factor (instead of size or shape), competency, modality, provided(with), provision(ing), irregardless/irrespective, signage, colorized, pulsating, ideate
  #4   Spotlight this post!  
Unread 21-09-2010, 20:11
dirienzo dirienzo is offline
Registered User
AKA: Nick DiRienzo
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2009
Location: USA
Posts: 15
dirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to behold
Re: Java versus C++

My original post did seem like I learned nothing this past year. Which is not true. I did learn how to program for FRC, but we never got our camera working (due to frame rate issues and what not). When I said 'new', I mean less than two years. Then again, I am comparing myself to programming veterans who have been doing it for 30+ years, or even the students who have been in their team's programming group for more than one year.

I am fairly comfortable in Java. I have taken an Intro to Java class at school (was quite boring) and now am in AP CS A. I also taught myself using Blue Pelican Java during the build season, up until about week 4 - which is when I started working with the prior leads and learning somewhat.

So there will be a slight learning curve for some things, but for the most part I will be fine.

Meh, I guess I could just write it originally in Java (what I am comfortable with) then rewrite for C++. And play around for myself.

@GGCO: A lot of the replies are just personal preference of a language. I understand that people use what they are most comfortable with. I was wondering if there are any proven gains or disadvantages to one language for the system we work with. Yes, there are some posts saying Java is not as good. But the supporting evidence was a matter of opinion. Thanks for the links though; more teams used Java than I thought.
  #5   Spotlight this post!  
Unread 21-09-2010, 20:23
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Java versus C++

All three languages have plenty of teams using them.

If you have a specific task you'd like to compare, I suspect you can get some numbers run. In general, all calls to do I/O and vision are neutral since the vision code is just a wrapper around native binary code, and the I/O is wrapped around the FPGA which is programmed in LV by the way. Differences will start to show up when/if most of the code being executed is written by you or your team. If you decide to get the pixels from an image and index through them looking for patterns, you'll notice a difference between the compiled and bytecode languages. Still, I think you'll find that reasonably written code will run just fine in any of the languages. So yes, it is a matter of preference, experience, and goals.

Greg McKaskle
  #6   Spotlight this post!  
Unread 21-09-2010, 20:43
dirienzo dirienzo is offline
Registered User
AKA: Nick DiRienzo
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2009
Location: USA
Posts: 15
dirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to behold
Re: Java versus C++

Quote:
Originally Posted by Greg McKaskle View Post
All three languages have plenty of teams using them.

If you have a specific task you'd like to compare, I suspect you can get some numbers run. In general, all calls to do I/O and vision are neutral since the vision code is just a wrapper around native binary code, and the I/O is wrapped around the FPGA which is programmed in LV by the way. Differences will start to show up when/if most of the code being executed is written by you or your team. If you decide to get the pixels from an image and index through them looking for patterns, you'll notice a difference between the compiled and bytecode languages. Still, I think you'll find that reasonably written code will run just fine in any of the languages. So yes, it is a matter of preference, experience, and goals.

Greg McKaskle
Alright, thank you. That cleared things up for me. Our mentor and I will probably run some individual tests anyway.
  #7   Spotlight this post!  
Unread 21-09-2010, 21:30
RoboMaster's Avatar
RoboMaster RoboMaster is offline
Alum, former programmer&co-captain
FRC #2472 (The Centurions)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Minnesota, Twin Cities
Posts: 268
RoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant future
Re: Java versus C++

I'm not an expert in this, but I have repeatedly heard that Java runs slow, which apparently is one of its big downfalls. Would this apply here? It seems people are saying all 3 languages run just fine in our case. So maybe what I've heard is a general and bias statement.





Personally I'm a big LabVIEW fan.... **hint hint wink *cough* wink wink**
__________________
My engineering blog: noeticbrainwaves.blogspot.com

I'm not slacking, my code's compiling
...and I'm using LabVIEW
  #8   Spotlight this post!  
Unread 21-09-2010, 21:43
dirienzo dirienzo is offline
Registered User
AKA: Nick DiRienzo
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2009
Location: USA
Posts: 15
dirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to beholddirienzo is a splendid one to behold
Re: Java versus C++

Quote:
Originally Posted by RoboMaster View Post
I'm not an expert in this, but I have repeatedly heard that Java runs slow, which apparently is one of its big downfalls. Would this apply here? It seems people are saying all 3 languages run just fine in our case. So maybe what I've heard is a general and bias statement.





Personally I'm a big LabVIEW fan.... **hint hint wink *cough* wink wink**
Do you mean Java runs slow in general, like as a desktop application, or in an FRC system? And I haven't tried LabVIEW, I'm not too attracted to it, but I'll probably try it out this year.
  #9   Spotlight this post!  
Unread 21-09-2010, 21:50
RoboMaster's Avatar
RoboMaster RoboMaster is offline
Alum, former programmer&co-captain
FRC #2472 (The Centurions)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Minnesota, Twin Cities
Posts: 268
RoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant future
Re: Java versus C++

More like Java runs slow in general on a desktop application.

I would give LabVIEW a chance and see if you like it. It's a little unconventional so some people are hesitant, but I think it has a lot of benefits. These include the intuitiveness of graphical programming, its excellent debugging tools, and easy learning curve (in my experience and as reported by many people). Here's a link that I just found recently about LabVIEW, it's very good. http://www.ni.com/labview/whatis/graphical-programming/
__________________
My engineering blog: noeticbrainwaves.blogspot.com

I'm not slacking, my code's compiling
...and I'm using LabVIEW
  #10   Spotlight this post!  
Unread 21-09-2010, 22:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Java versus C++

Quote:
Originally Posted by RoboMaster View Post
Java runs slow in general on a desktop application.

There are heavily computation-intensive exceptions but most desktop applications in general are not CPU bound and therefore they run the same whether written in Java or C++.



  #11   Spotlight this post!  
Unread 21-09-2010, 22:11
RoboMaster's Avatar
RoboMaster RoboMaster is offline
Alum, former programmer&co-captain
FRC #2472 (The Centurions)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Minnesota, Twin Cities
Posts: 268
RoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant future
Re: Java versus C++

Ok, thanks for clearing that up. I've just always heard Java is slow.
__________________
My engineering blog: noeticbrainwaves.blogspot.com

I'm not slacking, my code's compiling
...and I'm using LabVIEW
  #12   Spotlight this post!  
Unread 21-09-2010, 22:27
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Java versus C++

I will tell you that it is easier to code with Java. It can be a pain in the $@#$@#$@# to fix a memory leak in C++ because of a misused pointer... But personally I love C++
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
  #13   Spotlight this post!  
Unread 21-09-2010, 22:41
rogerlsmith's Avatar
rogerlsmith rogerlsmith is offline
Software Engineer
AKA: Roger Smith
FRC #3357 (COMETS)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Grand Rapids, MI
Posts: 214
rogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to behold
Re: Java versus C++

From my experience mentoring teams using both C++ & Java, I have not seen any kind of performance issues. If you already have experience in Java, go with that.

I have been posting some simple Java programming tips on my blog. Feel free to contact me if you have any questions.
__________________
Roger Smith
Mentor - FRC Team 3357
COMETS - Creating Outstanding Minds, Embracing Technology & Science
---------------------------------------------------------------------------------------

Share FIRST videos, photos and experiences at FIRSTObjective.org
  #14   Spotlight this post!  
Unread 21-09-2010, 22:56
RoboMaster's Avatar
RoboMaster RoboMaster is offline
Alum, former programmer&co-captain
FRC #2472 (The Centurions)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Minnesota, Twin Cities
Posts: 268
RoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant futureRoboMaster has a brilliant future
Re: Java versus C++

Quote:
Originally Posted by rogerlsmith View Post
If you already have experience in Java, go with that.
Well said Roger. Consider this advice when looking at your options, it is a very good point. It always comes up in discussions like this.
__________________
My engineering blog: noeticbrainwaves.blogspot.com

I'm not slacking, my code's compiling
...and I'm using LabVIEW
  #15   Spotlight this post!  
Unread 22-09-2010, 11:39
Jon Stratis's Avatar
Jon Stratis Jon Stratis is online now
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,816
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Java versus C++

The statement "Java is slow" has been around a long time. And at one point, it was true. When Java first came out, it was slower than other languages like C. But there have been a TON of optimizations over the past 10+ years that simply make that statement not true in most cases. In fact, due in a large part to memory management, C++ can be slower than Java (Pointers are time consuming to handle for C++, malloc sucks, performance wise. You don't have those problems with Java).

for a young programmer like yourself, you have a couple of options.

1. You can go with what you already know (Java) - that will be the easiest and surest way of producing quality code for your team. The additional benefit of extra exposure to the language through the team will also help you with your classwork. Looking towards the future (aka college), you'll most likely being using Java for a lot. I know my old school has switched many classes over to Java in the past 6 years or so. Having a deeper understanding of that language now will only help you with your classwork in the future.

2. You could go with a different language for a broader experience. While this will probably be more difficult and time consuming for you, most programming jobs generally involve multiple languages - and having a broad exposure will help in the long run. For instance, right now my job requires me to know HTML, Groovy, JSP, Java, SQL, PL/SQL, and C (i think that's everything...). Additionally, learning multiple programming languages helps you to understand the basics of how languages, in general, work. You don't need to deal with pointers in Java, but working with them in C will dramatically increase your understanding of how computers work.

One last thing to consider: What support do you have? Do you have any programming mentors? do they have a preferred language?

Our team ended up going with Java for two reasons - first, the students were familiar with it from classes at school. Second, the mentors knew it better than C++ and could help them succeed better with it.

Another team we work closely with made a different decision. They went with Labview (i think), and ran into some big problems late in the season that their mentors (who were experts in Java) couldn't help much with. Having a safety net of knowledgeable people close at hand isn't something to ignore.
Closed Thread


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
Cable Versus Chain Darren Collins Technical Discussion 1 14-01-2008 22:29
Bernoullis versus Continuity Corey Balint Math and Science 13 15-09-2007 17:59
PC versus Console Denman Chit-Chat 40 22-05-2005 18:01
Reigonals versus startegies MisterX Rules/Strategy 11 29-03-2004 00:04


All times are GMT -5. The time now is 23:18.

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