Whatever program you’re writing, it doesn’t matter what it is, just do it in Python first.
Python is… okay. It’s not as fast as C or Rust, it’s not as correct as Haskell, it’s not a perfect language. I’ve been writing Python code, both formally and informally, for more than a decade. There are many things about it which I don’t love, but it always gets the job done.
It’s easy. It’s readable even to non-technical folks. It’s readable to an English teacher. My first exposure to it was in seventh grade, when I was 12 years old, and I’ve been using it to write useful code ever since.
Python is a real, general-purpose programming language. It’s used by rocket scientists to launch satellites, then by a different set of scientists to analyze data taken by those satellites. It is used to train the LLAMA LLM.
Python is extremely accessible. I learned to use it with repl.it, but now in a pinch I can quickly spin up a Google Colab, which has all the main packages built in already without the need for an import. (If you need to import a new package, pip is built right in. Just run pip install numpy
as if it were normal Python code and it executes beautifully.) It’s built into MacOS, likely already installed if you use Linux, and running python
in a Windows terminal lets you install it in a single click. This accessibility is important for open source because it lets more people instantly understand your code, and for non-open source to allow other folks in your organization to understand your code without navigating unfamiliar syntax.
The language lets you do hard things easily. XKCD’s Joke about Python applies.
Need to make a GUI? import tkinter
. A secure password manager? import secrets
. Sending an email? import email
. A browser? import html
. This is all just the standard library, not even touching the wealth of well-optimized, well-documented 3rd party libraries such as numpy, sympy, matplotlib, pygame, astropy, plasmapy, scipy, pandas, and more. Many times, these libraries are written in a faster language than Python itself: Numpy, for example, uses C/C++/Fortran to speed up bottleneck operations.
There are few situations which I would recommend against Python. These are valid, because Python isn’t perfect. The first draft of any code should be in Python, unless…
I have tried a lot of different programming languages to find “the one” which fitted me best. Python is not a perfect fit for me. I would love it if I could write Rust with the same efficiency as I can with Python, because many of the decisions made by the Rust language have resulted in that nearly perfect language. C, Go, Java, and Javascript are decently fast and well-supported nowadays, too. I’ve needed to write MATLAB and IDL code for legacy purposes, for which I needed to learn them. But Python is a language easy enough to learn, simple enough to memorize, fast enough for everything with few exceptions, and expressive enough to do everything. Stop trying to find a programming language, just use Python!
Appendix: I went down a little bit of a rabbit hole to find out exactly how much memory Python uses, and it turns out to be a little bit difficult to measure at the bit level. The Resident Set Size was the best order-of-magnitude measurement I could find, which represents the portion of memory held in a computer’s RAM (as opposed to swap or something else). The memory usage for various programs were measured:
cat /proc/PID/statm
. These are the second numbers in the output.
Additionally, DOOM (1993)’s system requirements ask for 8 MB of RAM, so if you can run DOOM on something, you can definitely run Python on it.