I will not argue about the fact that c++ is in general definitely faster than java. And that of course is an advantage for coding contests. I will not lie, I like java more than I like c++(which in fact is my second favorite programming language) so I’ll try to show what I like in java better than c++ (even when it comes to contests).
Note: There is no “global better programming language”, there are only tastes and needs, you should choose your programming language considering this two points. And when you learn one programming language and become a reasonably good coder you should be able to adapt to other programming languages without much difficulty.
Ok, here goes (feel free to criticize and correct me as much as you need but if your argument is not strong enough and I’m not convinced I’ll probably try to show you why):
- Java is easier to learn than c++ and I would recommend any person who wants to learn programming to start with java:
- Java has THE VERY BEST documentation by far(and I honestly doubt anyone can argue with this).
- With Java you don’t have to worry about headers and I think this is a big plus, you have less files to worry about and it’s easier to focus on what’s important (this is not really important here but you never know).
- In java you don’t have to specify the size of an array on creation… there are ways to do this in c++ but I think java’s approach is way better.
- Java naming system is a big help, basically what you see is what you get:
- I really don’t like how c++ shortens the names of methods and objects like str, strcmp, I mean you have to deduce or memorize what those words mean, I know a lot of people will most likely call me lazy but I think it’s really harder to learn when you’re not used to those things yet. However in java you can learn those things without much effort and with a well organized api it becomes a lot easier to learn and enjoy programming.
- Ok, c++ is definitely faster than java but in no way java is slow. If your algorithm is good it will run fast. If you are really needing some kind of speed optimization and you already pushed the most out of the java code just write the same code in c++(java’s syntax is based in c like c++'s).
- It’s easier for beginners to handle exceptions in java.
In general I would strongly recommend start programming in java, and when you’re good enough you can start learning c++ (which is what I’m doing) and really it’s not that harder to translate from one to the other… But like the others said , you have to choose the language that makes you more comfortable to be your main language… And with that I don’t mean you should code a little more on one than the other… I mean you should become the best you can in one of them… Know the important stuff, know which approach works best in which situation and what can the language provide that can help you and you’ll see that whenever you want to pass your code to any other programming language and you already know this stuff you won’t have a lot of problems… I hope that my answer can at least prevent you from choosing something just for one reason, whatever your choice may be.