C++ Vs Java in contest

c-plus-plus
contest
java

#1

As i am a java user . Is there any advantage of learning C++ for programming contest?


#2

***** C++ is faster than Java in essentially all situations. C++ code is shorter and more compact. In most areas, C++ is superior to Java.

***** Slow I/O compared to C/C++, Slower in general, Lots of judges have problems with running contestants java code. It’s well-known that Java is slower than C++, which can sometimes hurt when an implementation in Java would lead to TLE when the equivalent implementation gets AC.

But if we implement the code in the proper way i think there will not be a problem with the TLE case. More-over choosing a language is a matter one’s own personal ease. Even there are times where Java has an upper-hand over C++

**->**Java is better than C++ primarily in that Java has some special packages like java.awt.geom and java.math that occasionally simplify solving some problems greatly. Some people say that debugging int Java has been easier than debugging C++. I personally dont know much about that. I am a C++ user.
If we are doing computational geometry problems, Java coders sometimes have an advantage with the java.awt.geom package. Tha major Advantage that Java has is the BigInteger/BigDecimal stuff which C++ misses a lot. Of-course we can implement using C++ but sometimes that tend to be tedious :slight_smile:

HAPPY CODING


#3

If you good in java and are able to solve problems , I don`t there is any need to learn C++ . Java can handle big mathematics calculations easily . Only problem I think is C++ takes less time than java But it is not a problem , since proper multiplication factor of time is used in contests . Also ACM-ICPC allows both the language , so there is no problem . But IOI allows only C++ , so if are aiming for that u may need to learn that .

All the Best . Keep Practising .


#4

java is platform independent whereas c++ is not. if you know java then it’ll be easy for you to learn c++. but i dont think there is any need
all the best


#5

Hey @bipin2 is there any chance for some problem on codechef which get TLE in java but not in c++ .I can solve most of the problem in java is there any need to switch from java to c++.


#6

If you are a good with JAVA then that is fine. I told right there are situations where we C++ users find it difficult to do some problems, whereas JAVA users can do it in very few lines. Every language will have its own merits and demerits. That is upto one’s choice. But is good to learn C++, the STL libraries etc because in case you get TLE you can shift to C++. I have not used JAVA to submit here. But i have seen many people saying that JAVA hurts them with TLE. But for ACM-ICPC type contests they set the time limit in such a way that both C++ and JAVA users will not have a problem :slight_smile:


#7

Thanks man suggest me how to shift from java to c++ . Give me some book reference or online reference for it.


#8

All i can tell you is just practice. Take out those questions which you have solved in JAVA so that you already know the algorithm for the question so that you dont need to spend time for that. Read others codes and get familiarized with the syntax. For all the functions in STL take use of this website http://www.cplusplus.com/


#9

Dont try these in Short Contests untill you are good in C++. You may loose your valuable time over there de-bugging because you may not be familiar with the language. Try these in Practice Section and in Long Contests :slight_smile: Hope this helps :slight_smile: