Блог пользователя livenlife453

Автор livenlife453, история, 2 месяца назад, По-английски

I've been using Java, and pretty much only Java, all my life, which apparently seems to be an unusual circumstance. Virtually all the top players I've looked at seem to use C++, or on occasion some version of Python. This leads me to wonder if Java is simply the "noob" language. I understand that C++ is normally faster than Java, but from what I've seen, problems are designed such that the correct solution will run in the required time regardless of language, as long as the asymptotic complexity is correct. Is this different at the top level? I don't know much about C++, (I only had to code some basic stuff in C for school), so this could be completely wrong, but I don't think there are classes or objects or any of those helpful things like in Java. I would think using C++ is more restrictive. I'm wondering if abandoning Java and learning C++ is something I should do sooner rather than later if I want to reach any reasonably high rating in Codeforces. I would really prefer not to, given I've used Java all my life, but if it's virtually required, it would be nice to know ahead of time.

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

for most problems, it does not matter what language you use. only at the top level you might see the performance overhead of high level languages causing issues.

also note that such high level languages are more practical than c++ for most production code, especially that which heavily relies on OOP.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

C++ is not only fast but also provides very optimized and efficient standard template library(STL) compared to other languages

»
2 месяца назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

Yes, for CP, C++ is from a superior race. Hitting time, memory or recursion limit is an issue in other languages. One other issue is that some Python libraries like SortedContainers are not available in CF.

»
2 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

On CF, yes, you are correct that contest authors are supposed to make sure java and python pass.

With that being said, that doesn't change the fact that C++ will be faster. You will occasionally have TLE hell problems 2228D - Sanae, Cross and Color 1715D - 2+ doors that will be easier to pass in C++. Or like 896E - Welcome home, Chtholly that can be completely cheesed using AVX.

I'd suggest that you learn C++ if you're interested. I don't think it will be costing you that much rating in the long term. But it should not be terribly difficult, all the languages work approximately the same. (Although there are some unique gimmicks in C++. I've yet to see a good resource that covers many of them.)

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

you are a potato

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

As a Java user, yes, you can definitely reach "reasonably high rating" using Java :)

But here is my recommendation: you should learn C++. I plan to learn C++ soon. Though, it only makes a small difference.

At low levels, most languages are about the same. At higher levels, C++ starts to take the lead for a few reasons.

  • Java is slower than C++. Most of the time this isn't an issue, and you don't get TLE. But sometimes, rarely, it matters. For example, 2228D - Sanae, Cross and Color, where I wasn't able to solve in-contest because of Java TLE (374852558).
  • C++ has useful features that Java doesn't, like operator overloading. This lets you write shorter code, which can save you a few seconds (and your sanity).
  • C++ is the lingua franca of CP. Basically everything from editorial solutions to ICPC templates will be in C++.

Regardless of what language you use, you should be as familiar with it as possible. Learn all the quirks and useful APIs, so you can write code in that language fluidly.

P.S. I see you are from UT. You're probably in the same boat as me then—you learned Java in high school to participate in UIL :)

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
  1. C++ has classes. I don't know any major feature that would be present in Java but not in C++ in some way (although that's not saying much; I don't know anything about Java or C++)

  2. You definitely can be a successful CPer in Java. The language is almost never a bottleneck.

  3. But it is probably easier with C++. Just because almost everyone uses it, it means that you have much more material to learn from.