Python is Holding Us Back

Python is holding me back from being a first class computer scientist:

  • Python has no tail call optimization, which means recursion is off limits. What kind of half-baked language doesn’t offer recursion? I recently encountered this with a class that called itself to recover from network disconnections. This will work only 64,000 times, or whatever your system’s stack depth happens to be. So the server has been dying about once every month. If I keep this server in Python, I will have to rewrite it in an obtuse way so it’s not self-referential. Your college professor’s recursive Haskell brain-teasers may not have been very readable, but many examples of recursion are dead-simple and shouldn’t be re-written as external loops.
  • There is no static typing or composable types. It would be nice if I could know that types are correct without having to run everything to the end of the universe to discover a simple type error. Some academic languages (Haskell) beat the programmer over the head with types. Somewhere in the middle would be nice.
  • Python itself is extremely slow. Anything that requires performance is written in C++ anyway and then a Python API is written on top of it. If you ever needed to do anything novel that performs well, you wouldn’t be able to do it in Python anyway.
  • Python hides too many concerns. The Python programmer never asks, “What’s the optimal big O algorithm out there for this task?”, and then implements that algorithm. That would be suicide, because Python is so slow. Instead, the Python programmer Googles around until finding a handful of numpy routines written by someone else for a different task but that work well enough. The algorithm in use is a black box. That’s not computer science, it’s Googling. This hiding of concerns is great for beginner and intermediate programming, but not for computer science without a ceiling.

Python has a lot of nasty patches for these flaws: “Just use Cython,” or “Just use mypy.” These are sorry excuses for the language itself acting as it should. Neither mypy nor Cython worked well in my experience. Do I want to be a Cython expert or do I want to be an algorithms expert? I am interested in the fundamental, not the incidental.

Let’s not be draconian about it. If I want to use BERT embeddings, I will surely just take Google’s Python implementation and run it. No need to rewrite and retrain BERT from the ground up in some new language. This may be a bad example because I could probably also run Google’s BERT models in C++, and C++ does not have any of the ceilings I mentioned above.

The more I use Python, the more I am inclined to use Python because it’s what I’m familiar with. 10 years from now, will I be happy with being a Python expert? I think not. I will look back and wonder what kind of computer scientist I could’ve become had these artificial ceilings not been imposed on me.

Written by

A democracy of genes.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store