In search for a good programming language: Python

Python is a language of which I've seen very few people say bad things, and I think that speaks something about the language design, given its demographics of users and the volume of hate that other languages get. The few criticisms I've heard about are centered around: (1) performance, (2) dynamic typing, (3) significant whitespace, and (4) the GIL. I don't think any of these are deal-breakers.

Performance is of course the most-cited problem of Python, and it's basically the canonical example of "slow". Indeed, if you look at any benchmark (such as speed comparison), you would basically always find Python (CPython) at the bottom, perhaps next to Octave and Perl. PyPy grants performance on par with a bunch of mainstream languages, and if you want to go the extra mile, you would have to go native and use Julia, C, or Rust. But I think the problem is severely overstated. It is true that if you ever execute 10M lines of Python code, you probably have to wait a while, but in practice, the time spent in the Python realm is small compared to the underlying native library. Novices may be implementing entire list processing algorithms in Python, but any seasoned developer would know from muscle memory to offload the heavy lifting to native libraries like NumPy or Pandas. Nevertheless, the popularity of tqdm relative to other languages already says something about Python performance.

Dynamic typing had caused me problems about 5 years ago, but time has moved on and the type checking ecosystem is getting better every year (I haven't used an untyped library in a while). Pyright is comparable to TypeScript in terms of ergonomics, although the type system, being standardized by PEP instead of a single team like TypeScript, is not half as powerful. Still, it's good enough for most use cases, and I have enjoyed its syntax and semantics more than TypeScript. Python, since its day 1, is also in a much better position than JavaScript at enforcing strictness, because it tends to reject invalid types instead of coercing them, and it has a much more consistent and predictable runtime type system. The int/float dichotomy is especially useful in most contexts.

I wouldn't consider significant whitespace a problem, and I'm baffled by who's getting tripped by it. Even in languages like C or Java, people are still expected to have consistent indentation, and it's not like people would seriously write code with random indentation. Haskell, also being a language with significant whitespace, has received close to no complaints in this regard, which speaks volumes about the demographics of the complainers. The meme of "writing Python with rulers" also seems to be dying out over the last 10 years, a sign of people migrating to real editors with real indentation support. Indeed, it shouldn't bother anyone writing code in an environment more sophisticated than Notepad.

The GIL is a problem for sure, but I suspect some people citing it may not have a visceral understanding of it. To be honest, I fail to see how it's operationally different from JavaScript's single-threaded event loop. Both of them allow the creation of separate processes that communicate via some IPC mechanism, and you can use async/await to implement concurrency without parallelism within one process. The GIL is also on its way out, by the way.

There are also some other tensions. Dependency management isn't easy in Python, especially with multiple Python versions and global package installations. (The recent uv tool may solve it in the near future.) Python 2 to 3 transition was a nightmare for many. On the other hand, there are far more things that Python gets right, which is very remarkable for a language that's as old as VB and Pascal. Module system; explicit self parameter; strong typing (not to be confused with static typing); context managers; syntax for list/dict/set; operator overloading; the list can go on. It has consistent and high-quality aesthetics (which gives birth to things like True and False that may baffle some, but I find them laudable). All these features pave the way for a very pleasant programming experience.

Many people have pondered the question of "why Python". After all, it's not born in big corps (like VB for Microsoft, Go for Google, or Java for Sun), doesn't have monopoly on one platform (like browsers for JavaScript or iOS for Swift), doesn't have a unique selling point (like Rust for safety), and doesn't even have good performance. Its success proves that none of these are necessary for the acceptance of a language, which is certainly a morale boost for most PL designers: it's possible to attract users just by making your language beautiful and ergonomic without finding a niche.

On the other hand, what would be the counterfactual had Python not been the default scripting language? Tools like Django, NumPy, and Pandas only came out circa 2005, at which time we had many other thriving scripting languages like Ruby, PHP, Bash, Perl, JavaScript12. But when looking closer, it's immediately apparent that none of these could compete feature-wise (or even performance-wise) with Python:

Under a comparison like this, Python is the only one that strikes the balance between expressiveness, dynamic typing, abstraction, and aesthetics. So perhaps the success of Python is not so much by chance—its forward-looking design deserves the attention it gets.

Footnotes

  1. It's also funny to remark that, except JavaScript, all of these languages appear at the bottom of the speed comparison.

  2. Many people may say "Python succeeded because of NumPy/some other package", but it's a chicken-and-egg problem. Why must it be NumPy, and not NumJS or NumPHP? Once we start asking these questions, we start to go back to the language design itself.