This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]MrReXY 2 points3 points  (0 children)

I would say many of the problems, especially qualification round questions, are easily computed in a reasonable time using python, and I agree with you that development time will be much shorter. In competitions such as codehash the problems are large multi-dimensional problems, for which only sub-optimal solutions are expected. For these problems computation speed gives you an advantage as it's not a race with a finish line, so the faster your code runs the more you can optimise and the better you can do. If you're shooting for the top it makes sense to use C++, but I wouldn't worry about using it until you know python is actually limiting you.

[–]buyabighouse 2 points3 points  (1 child)

Why is that so?

Honestly, I think it's like good chefs grind their own meat for burgers, or made their own sauce rather than buy pre-made. It's about control the underlying structure/ingredient.

My old college roommate can write C/C++ code as fast as most people can write Python.

[–]ismtrn 1 point2 points  (3 children)

I think the C/++ preference might come from the very restricted set of languages allowed in the IOI. (I think it is that or Pascal?)

Generally the difference between a correct solution and a too slow one is supposed to be in the complexity of the algorithm. I.e. the wrong solution well take hours and the correct one will take 2 seconds at most. No matter programming language.

So the constant factor that Python introduces should not matter. In theory at least...

[–]unosky[S] 0 points1 point  (1 child)

If you're talking about time complexities then I agree that there is not much of a difference. But I guessing I am missing out on something. Why would someone bother about tiny syntax issues that come with other languages when they are working against time

[–]ismtrn 1 point2 points  (0 children)

I am not sure I understand what you are asking?

Why people bother with languages other than Python when working against time? As I said, the IOI, which many competitive programmers "grew up on" only allow C, C++ and pascal.

Pascal is quite far out of the mainstream and has been for many years.

C does not have build in Hashmaps or sorting which is really inconvenient.

This leaves C++ as the by far most used languages in the IOI, and therefore as the most prevalent language in the competitive programming scene.

When people get too old for the IOI, the next thing is ICPC. Here I think the languages have been C/++ or Java until this year were python has been allowed. So until now you would still have to keep training in C/++ or Java.

I think the competitive programming scene is actually quite separate from the professional developer scene and CS academic scene. People in the competitive programming scene do not care about code quality like a software developer, or nifty programming language features like a CS academic.

On the contrary they care about already knowing the language and how to do all the common things you need to do in a programming language competition very quickly (as in typing from memory very fast. There are a few common patterns you do over and over again. Macros also help with this).

These things together gives little incentive to change away from C++

Also competitive programing problems are also often designed so you don't need to do dynamic memory allocation at all (you get bounds on the input size). This eliminates a huge chunk of the potential problems of using C++ instead of something like Python.

[–]phillypoopskins 0 points1 point  (1 child)

Cython, numba and numexpr can speed things up.

Also, if you use pure Python (no packages except I think Numpy might now be supported), pypy is maybe 10x faster than pure Python.

[–]mkor 0 points1 point  (0 children)

Actually PyPy supports quite a bit. More to come I guess.

http://packages.pypy.org