C++ vs Java

This year, I am my team’s new lead programmer. I’ve been doing some Googling about the differences between the two programming languages but I can’t decide which language to go with.

I’m much more familiar with the syntax of Java, but I’m a very fast learner and should be able to figure out how to use C++. Also, all of my teammates who could help me taking the AP Computer Science, which teaches Java. I have prior experience with the FTC’s RobotC, which if you aren’t familiar with is basically a more simplified version of C++ and the WPILib.

I understand that compiled C machine code is more efficient than Java bytecode executed on a virtual machine, but is the performance difference really significant enough to be noticeable at all?

If any experts or mentors from other teams could give me some advice or feedback, it would be much appreciated. (: Thanks in advanced.

I believe that the execution speed in this application between the two languages is not important.

The java libraries, as I would consider them, are still under development. For instance the wrapper for the camera imaq* is mostly missing.

That being said you certainly can still track targets just its a bit harder.

For all intensive purposes you can completely program the robot without issue in java and c++ so it comes down to a personal decision. . .

Which language are you more comfortable with?

No. For purposes of FRC, this should not be a factor in your decision.

**

In FRC, most of the differences between the two languages are irrelevant. Both languages can accomplish anything you want to do in FRC. Unless you are doing some particularly intense programming, efficiency shouldn’t be a concern.

As drakesword said, it should come down to what language you and your team are more comfortable with. If you want to learn a different language during the off season, go ahead. During build season you should stick to what you know.

That being said, java and C++ have very similar syntax, as you will find many high-level languages do. The key difference you will run into in FRC is that C++ uses pointers, whereas java does not.

I prefer Java due to the officially used IDE being NetBeans. I prefer being able to use the opensource IDE available to many Operating Systems than Windriver for C++.

Your team number indicates you are a pretty new team. I would suggest two things:

  1. pick a language and start right now (I typically recommend that teams start before the season getting familiar with the programming environment. You have a bit of catching up and will be better served by putting in time than listening to the endless discussion that C++ vs. Java usually provokes :yikes: )
  2. if there is a local team that is willing to support you (many larger older ones are extremely helpful) you might want to use the language they use, as experienced help standing next to you is worth a thousand posts. That said do not despair if you don’t have local resources, request here often generates a thousand posts :smiley:

Good Luck!

I agree with the others, which one you choose really doesn’t matter. I actually find the fact that the vision stuff isn’t fully wrapped in java forces you to simplify the vision code, which in the end could very well be a good thing.

If you are interested in Java shoot me an email, [email protected] I have all my code open sourced with tutorials this year. I go into a lot of the things you probably will see on the AP exam like interfaces and abstract classes.

There is quite a bit of discussion on this topic already in the forums. So next time search before posting.

We use JAVA because:

  1. students learn Java in AP courses
  2. garbage collection & great error handling!
  3. Netbeans is a friendly IDE for first time coders

If you want more JAVA sample code , take a look at our code base from 2010 or if your brave, our 2011 development code.

http://code.google.com/p/discobots/downloads/list

I looked through the WPILibJ Java documentation last summer so I’m a bit familiar with it, but I’ll probably still be coming back here for help.

Yeah, having my code portable among different operating systems is nice. I can code on my laptop (both the Windows and Linux paritions) and my school’s iMacs.

I did do a quick search but obviously I didn’t look thoroughly enough. I also agree with all three of your reasons. Thanks for the link! I’m sure it will be very helpful.

Thank you to everyone for responding. I’ve decided not to make things more complicated than they need to be and use Java. Good luck to everyone and see some of you at the competition. (:

For FRC-specific purposes it does not matter whether you use Java or C++, but I would recommend C++ as it will help you develop a knowledge of programming that applies to a larger variety of languages.

I recommend C++. The libraries are more mature by a year and the syntax is similiar enough to java that you will pick it up in no time. Post any questions and I’m sure somebody will help.

Brian

Main reasons why I chose Java:
1.) Simplicity
2.) I am the only one that knows C++
3.) NetBeans is Open Source (Why do I care? Because I run Linux, so I can code on my machine at home)
4.) AP Comp Sci teaches Java

Cons:
1.) No inline Assembly
2.) No pointers
3.) Too high level for my liking

Can you show me some FRC code you have written where it was necessary to inline assembly?

Nope:yikes: