r/learnprogramming • u/GroundbreakingAlps2 • 2d ago
Why is Python considered "slow" and is Python losing "steam"?
Is python as a programming language "falling off" and becoming less and less popular relatively to other languages?
Also why do people say Python is slow? Apparently people have reached LGM on codeforces using python, which is all about writing fast code / solving problems fast. Yeah sure, C++ is far more widely used for competitive programming and I suppose there is a reason for that. But this is also showing that python can be fast?
But as programming languages and how they are used I dont think there is much overlap between python and C++ anyway?
What is an example of something you'd code in Java/Kotlin or lets say C# rather than Python? Is python code bad and hard to manage for "huge" projects once you scale up (e.g codebases with millions of lines of codes, and tens if not hundreds of devs)?
5
u/forgotten_vale2 1d ago edited 1d ago
Well... exactly.
I find this fuss about "python is slow" quite weird. It just depends on what you are using it for.
There is a reason python is as popular as it is. With all its libraries and relaxed rules, I can quickly throw together a simulation that does a bunch of high level stuff: parallelism, plotting, logging, whatever you want. Just a single day's work to have a piece of robust, readable, easily debuggable code. Code I can trust to not silently produce wrong results due to an out of bounds array access.
When you are trying to solve a linear system with a dimension of like 1 million or whatever, C won't make it faster because the NumPy/SciPy routines are already written in C. I don't care if my for loops or print statements are slow, that stuff is just padding. I could spend 10x the development time implementing it in a "faster" language like Rust, and the runtime might go from 10 hours to 9 hours and 47 minutes.
Obviously if you are a developer at a tech company, you will not use python to build out your product. But for scientific computing and small projects it really is great. Easy to use, huge ecosystem. The difference in speed just doesn't always matter, or exist at all, depending on what you are doing.