“Use the right tool for the job” is a golden rule of engineering. Working on software, however, there are often dozens of different languages that can get the job done. How can you know which one constitutes the right tool for the job? Some programming languages are designed with one use in mind, but most try to be general purpose. One language that stands out for being general purpose and yet often out-performing languages custom built for the task is Python
In this post we’ll look at some of the reasons to choose Python whenever it's in competition with any other language for the "right tool for the job” status.
This was actually a quote from Dan Callahan, speaking at PyCon 2018. If it's the second-best language, why not use the first-best language? Simple — because then you’d have to learn a whole new language. Unless the gulf from second to first best is significant enough – if the custom “made for the task” language provides indispensable features and performance improvements – it simply does not pay to learn a new language when Python more than suffices.
When you work on a truly diverse set of problems, it helps to have a complete mastery of a language versatile enough to tackle any and all of them. For me, that language is Python.
You can go a long way writing Python before you have to download some external dependencies to make your code do something useful. Node.js and JavaScript are an example of the opposite — if you need to do anything there, you are npm install 'ing something and now you are down a road of tracking those dependencies and dealing with when they break. Not so with Python. The Python Standard Library is expansive and robust enough to tackle most problems.
Here is an amazing example of "batteries included" at work in the wild. One of my favorite conference speakers, David Beazley, got a gig doing eDiscovery for a legal case. He had to sit in a secure room and process 1.5 TB worth of source code looking for certain patterns. All he had to do it with was a computer with a fresh OS install, and no Internet connection. He had no way of bringing in additional programs or downloading any libraries, but the computer happened to have Python installed. So, he wrote his own set of tools on the spot to aid in sealing the deal on that case.
You're not likely to find yourself in quite the same extreme circumstance, but you will still benefit from minimizing dependency management and building more robust applications.
It's hard to overstate what a blessing the Python community is. Writing Python puts you in a community with a vibrant, diverse, and enthusiastic cadre of developers, designers, scientists, and more. You can attend multiple conferences all over the world and meet all the exciting people working to make Python as great as it is. I should know, as I have attended 16 PyCons (in a row!) and 5 EuroPythons, plus many regional events such as PyOhio and PyTennessee.
If you write Python, you'll have by default a huge pool of information and resources to educate yourself and write better software. Additionally, if you decide you do want to avail yourself of external libraries, Python has over 100,000 of them. If there's something you can't do with the Python Standard Library, chances are there's a library out there that adds that capability (or one is being written). You can contribute to these libraries yourself, and if you want to write your own you can get a lot of support from the community.
There is a good reason that Python is the number one teaching language on this planet: it is easy to get a new person started. There isn't a lot of boilerplate or ceremony to build a program that can actually do useful work.
If you work at a company that's growing – therefore, constantly hiring new talent – running a Python codebase means virtually every employee you hire will already have some experience with the language. This cuts down on training cost and time significantly. Your junior engineers can go from hired to writing code in record pace.
Then, on the other end of the equation, you can look to applications like Instagram, which uses the Django Python web framework to serve a tremendous amount of requests each day. For tasks like this you can rely on features such as static type hints to ensure your code is bulletproof and more easily testable. Here is where your senior engineers get to flex and build Object Oriented models and optimize performance.
These are the 4 biggest reasons why I keep coming back to Python after all of this years. Ultimately, every project's requirements will dictate which tool is the right tool. However, if Python is an option, and statistically it almost always is, it's an option you should consider.