Back

All USACO courses in Sparks Academy use C++ as the primary instruction language. We are often asked about the reason why we don’t use the seemly more popular language such as Java and Python. Let’s look at some facts first. The following is the statistics from 2021 USACO US Open Contest. In total, there were 10635 graded submissions, broken down by language as follows: 

 4590 C++17
 2572 Java
 2140 C++11
 1267 Python 3.6.9
   52 C
   14 Python 2.7.17

C++ and Java are the two most popular languages used in USACO. We don’t have the statistics about the gold and platinum divisions’ submissions. So let’s look at the statistics from the ICPC contest which is the most prestigious programming contest in the world. In ACM ICPC World Finals 2019, the most popular language was (as usual) C++, this year by an even wider margin than usual: more than 95% of all submissions were made in C++.  (Source: https://www.csc.kth.se/~austrin/icpc/finals2019solutions.pdf)   finals2019solutions

Advantages for using C++ over java:

  1. You can write your solution quicker with C++.  Java is too verbose. For example: System.out.println vs cout, Arrays.sort vs sort. 
  2. Since C++ runs much faster than Java, you will have more time to debug your code. You will be able to submit your solutions to USACO judging platform more times. Since there is no penalty for multiple submissions, this is also an advantage.
  3. The time limit for Java submission is 2 times the time limit for C++ submissions. But for some computational intensive problem, C++ runs 8~9 times faster than Java. Let’s look at the following example.

2022 February Contest Silver Problem 2

Time limit: 4 seconds for C++, 8 seconds for Java

 Best C++ Solution: 52 lines,  1388 characters

 

Best Java Solution: 92 lines, 3466 characters

13 'b 131

Conclusion: Java solution is about 8 to 9 times slower than C++ for this computational intensive problem. So even for silver level, the students should use C++.