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

Автор Guwanch1, история, 3 года назад, По-английски

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!

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

»
3 года назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

go for c++

»
3 года назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

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 года назад, # ^ |
      Проголосовать: нравится +12 Проголосовать: не нравится

    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 года назад, # ^ |
        Проголосовать: нравится +4 Проголосовать: не нравится

      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 года назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

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 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

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

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Avoid j*va :3

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why not C# on codeforces?

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    3 года назад, # ^ |
    Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

golang

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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!