Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Guwanch1's blog

By Guwanch1, history, 3 years ago, In English

Hello, i am newbie and c++ coder, give me an advice, should i learn Python or Java, or both of them or there's no need to learn these languages? Thank you!

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

go for c++

»
3 years ago, # |
  Vote: I like it +19 Vote: I do not like it

It fully depends on what you are doing. For CP C++ would be the best, for ML its python and Java for Web/App.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +12 Vote: I do not like it

    The problem is that Java isn't even that great for web dev tbh. JS and it's variants are just so much more prevalent in the real world... The only legit time I've ever actually used Java in the real world is for android development unfortunately, other than making games for fun.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +4 Vote: I do not like it

      Java isn't really strong in anything to be honest... it's main strength is that it's very widely used. The phrase "too big to fail" comes to mind there.

»
3 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Java had been removed from IOI since 2021. I don't think that it offers anything that the other programming languages can't do much better.

Python is very good for quick prototyping, for generating testcases when stress testing and for other automation tasks. It is also useful for the things other than competitive programming, so learning it is a good idea.

The main disadvantage of C++ language is poor safety. It's very easy to shoot yourself in the foot when not paying enough attention, and then spend a ridiculous amount of time on debugging. There are other programming languages, which are almost as fast as C++ and also much safer. Maybe Rust? But it's still not clear, which programming language will end up displacing C++ for new projects in the future. There are too many of them and they are all still evolving.

»
3 years ago, # |
  Vote: I like it +15 Vote: I do not like it

I've been running solo python so far on codeforces.

Speaking from a purely competitive programming perspective, C++ is superior for several reasons:

  • Convention: Every single contest will have C++ as an accepted language. To my knowledge, C++ is the only language allowed for use in my country's IOI qualifier.

  • Speed: C++ is the fastest out of the languages you listed. With other languages, you may have higher chance to receive the dreaded TLE error.

  • Standard: All testers, problemsetters, etc are likely designing the problems to be solved with c++.

I personally still use Python because I feel most comfortable with it. However. knowing the properties of your language of choice is important. In my case, I often have to code around Python's pitiful recursion limit. If you're completely new to coding, I would recommend that you don't do competitive programming / algorithmic stuff and instead do basic projects, like tic-tac-toe, etc. I don't think you will enjoy solving codeforces problems if you're busy wrestling your language at the same time.

Also, it goes without saying that outside of competitive programming, all three languages have their own strengths and cover very different scopes.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You can try pyrival library. Its having generator for python named bootstrap which is very helpful in recursion. In addition it is having fast IO template through which you can also submit your python 3.7 code in pypy2(which is very fast). It also got many cool things like alternative of c++ ordered set in python.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

most of the competitve programmers prefer c++ for its sheer speed , and extensive STL... but i have also seen people reach CM programming in java!! Go for C++ since you know C++!! Toss python

»
3 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Start with whatever you know now... You'll eventually shift to something which you're comfortable soon

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Avoid j*va :3

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why not C# on codeforces?

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    C# is exists on codeforces."C# Mono 6.8"

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Yes, but I found people rarely use it, along with pascal.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For things like recursion you should always use C++, because recursion takes more time to compile in python

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    More time? Often recursion doesn't even compile in python, to tell you the truth!.. But luckily none of that prevents us from successfully running it :)

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

imo c++ is the best for competitive programming but sometimes python is much easier to work with

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

golang

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For competitive programming c++ is probably the best choice. Here is an example from Junior Serbian Olympiad in Informatics 2019.

The allowed languages were c++ and python. Time limit was the same for both languages. The 4th problem involved quite a big input data. In order for optimal python solution to pass, they had to increase time limit and put smaller test cases. When they did that, a simple brute force was able to pass for c++ solution, while python programmers had to come up with an optimal solution.

It was a huge advantage for c++ programmers because they can write brute force in 10 minutes and solve an entire problem, giving them time to work on other problems.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Java and Python are Interpretive languages which run on virtual machines,and they are slower. C++ is a compiled language,C/C++ code will be compiled to machine code,and it's faster. So,due to avoid time limit exceed errors,I think C/C++ is best on online judging websites. Of course,Java and Python have their uses!