In this post, I want to look at the biggest strengths and weaknesses of Python, with more emphasis on the weaknesses, just because these problems have been there for years now and some of the rough edges bleed a lot.
The Good – Where Python Shines
Python is now the number one choice for many fields--beginners learning programming, machine learning, data science, and its poor ugly cousin, data engineering (which includes cleaning up data, extracting data and putting in an easy to read format etc).
For some fields, Python isn't Number One, but it is a strong contender. Web app development, specifically the back end part. Test and automation, again mainly backend, plus server applications. One startup I worked at was using Powershell and C to do its automation, and this led to fistfights until I graciously intervened and announced we were going to use Python instead (I may be exaggerating, but you get the idea).
If you are doing anything on Linux servers, chances are, if the script is more than a few hundred lines, most people will prefer Python over Bash. At one company, reviewers would start moaning over any bash script over 20 lines; and I don't blame them.
I've seen a comment far too many times: X is a great library, I would try it if there was Python support. Many apps are shooting themselves in the foot by not providing Python support.
So if you are learning programming in 2021, or trying to pick up a new skill, Python is a great option.
The Bad – Where Python Sucks
1) Installing Python libraries is hard, and often a hit and miss affair
Every time I say this, I get pushback. In a previous version of this article I shared in a private group, the most common comment was:
I've never seen this problem, are you sure you're not just imagining it?
And people on Reddit/HN get downright rude LOL, you can't even install Python, you must be stupid or some version thereof. One person told me, with 100% seriousness, that all my problems would go away if I just learned how to use a virtualenv. And I was like, thanks a-hole, I never thought of that.
For a brief period, I thought maybe I was stupid. After all, all these intelligent people couldn't be wrong, right?
Just a few minutes of searching showed me quite a few examples of other people suffering from the same problem:
So why does this problem exist?
I find that if you stick to very standard web dev libraries, like Flask/Django, mostly pure Python code, everything works fine. And that's why people can say, with all seriousness, that Python is easy to install.
The problem arises in 3 situations:
- Data science, Video/Image processing, gaming, or other libraries that have a lot of C/C++ code
- Trying to give Python code to a non-programmer, or even a non-Python programmer
- People like me who like to try out a lot of new libraries, just to learn new stuff
Just in the last 2 weeks, I had code that was working suddenly stop working when I updated a library (which I had to use a newer feature; also see the backwards compatibility section below).
I was trying a new gaming library– and it just wouldn't install on Windows, but worked fine on Linux. Windows is still a 2nd class citizen in the Python world.
And to make it worse– I got different errors when I tried using pip install vs conda install. And different errors on different Python versions– we are talking about small version differences like 3.7 vs 3.8
I can't remember how many cool libraries/projects I've had to abandon as I couldn't even get the libraries installed.
And it becomes a nightmare if you want to share your code with people new to Python. When I was writing my books, I found it easier to ship a 5GB virtual machine with everything installed, rather than try to help people install Python (and lots of other authors were doing the same thing, at one point I had a folder with 60-80GB of virtual machines, just for Python).
There is only one and 200 ways to do it
The Zen of Python, which people have stopped quoting (I wonder why), says:
There should be one-- and preferably only one --obvious way to do it.
Yeah, sure, pal. Maybe in 2002.
- Want to create isolated environments? Great! You have virtualenv, virtualenv wrapper, pipenv, poetry, conda. And somewhat related, though slightly different use case: pyenv and pipx
- Install Python or libraries? You can do pip install, apt install, brew install, and all will mess up your system in different ways
- Random libraries will come in and mess up your system Python
Now, the Python elite will look down from their nose and say Ah, ole chap, but you are supposed to use blah blah blah to make your work easier.
But beginners don't know all that (and seriously, should they be forced to learn if they just want to try out a script?)
Programmers with 10+ years of experience(but new to Python) struggle with this.
Code written today may break tomorrow– Backward Compatibility is a Joke
A Java programmer once insulted me(well, he was complaining generally, but looking in my direction, so I took it personally):
I have this code written in Java7 (which was 9 years old at the time), and it still works today. With Python, last week's code wont work today
I was ready to challenge him to a duel; took off my gloves and my flintlock pistols and everything; when I paused. The dude had a point.
This problem is mainly with libraries, but there is a move fast and break things that is very irritating. Libraries are re-written/refactored for no reason I can see.
Yeah, I get it. Sometimes, you have to refactor code. The code is maintained by unpaid volunteers etc etc. But I wish the community was more strict about backwards compatibility. All the "grown-up" languages are.
Summary, tldr, and where I try to make up
I realise this post comes across as very negative to Python. But I still love and use Python daily, and hope it improves and gets better. So much so that anytime a Rust programmer even thinks about opening their mouth, a dozen Python programmers jump in and say Actually, you should rewrite it in Python.
The tldr is:
- Python awesome to find a job
- Python is fun to program in, and super productive
- Problems are installing libraries and actually distributing your code so others can use it