Java vs. C++

Hi CD community,

We need help. Our old programming mentor has gone to college and he used Python. We tried to use Python this year but kept running into issues. It was recommended that we switch to C++ or Java. Which one should we use? What are the pro’s and con’s and which would be easier to learn and implement especially so close to the competition? Any input would be appreciated.

1 Like

Java would be easier to implement, no questions asked. You may want to try solving your problems with Python though if it’s this close to competition and you already have a lot of code done. You can ask for help on the FRC Discord.

2 Likes

We actually hardly had any code written. We were just trying to get our drive motors going but we couldn’t download the code for several unknown reasons and/or reasons outside of our control. But thanks for the input!

If you don’t already know C++ well, the big difference between the two is that Java protects you from yourself a lot better than C++ can. Unless you need that to-the-metal performance C++ can give, (and trust me, you don’t in this case, the RIO has power to spare for all but about six or ten teams doing complex multi-part autonomous or AI), Java all the way.

5 Likes

Thanks!

It probably makes sense for you to switch to a different language at this point, but I’m curious what specific issues you ran into when trying to use RobotPy this year?

2 Likes

I’ll have to get back to you on that. I’m not our teams official programer, however our current one is kinda slacking so I’m doing my own research.

1 Like

Java is slightly easier, cpp is slightly faster.

2 Likes

If we go with Java, what IDE should we use?

https://docs.wpilib.org/en/latest/

VS Code. Everything you need to know is on this site. :slight_smile:

5 Likes

Thanks!

Visual Studio Code; IMO it is the best IDE for most languages which allow it. WPI has a specific build for it here: https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/vscode-basics.html

3 Likes

Download FRC VSCode 2020. Follow this guide, it’s pretty easy.

Creating a working TeleOp is pretty simple, and considering this year’s game, you should be able to write an Autonomous that uses a Timer to move off of the init line. Tbh that’s all you should really try to do code-wise, and get some driver practice in after you get that working. Reply if you think you need more help learning how to write that code…

3 Likes

Our school teaches C++, we use C++. If it taught Java, we’d use Java. I am the main programming mentor, and I have the most experience in C++ (from programming in C++ on the team and being taught it at the school), but I have a touch of experience in Java.

I’d see what (if any) your school teaches first (since it is more likely for students to come in knowing whatever the school teaches), and make your decision based off of that.

+1 for asking help on FRC discord, you can usually get a helpful response within 15 minutes from people who either write WPILib, or are very knowledgeable.

1 Like

the school system here isn’t good so they don’t teach any code

1 Like

So I tried to download the WPILib for Mac from Github but my MacBook won’t let me expand the file. Says it’s an unsupported format. Any advice?

It looks like you didn’t get the whole file… it says it’s 367 bytes, it should be over 1 GB.

4 Likes

oh yep, it didn’t download all the way.

Is there any basic robot code from Github?

bc I’m very lost on where to start