One of the most common questions I see on learning python forums is “What is python best for” or some variation of it such as “Is python good for GUI?” or one of my favorites, “is Python the greatest language ever for AI?” And if you’ve landed on this page you either have this question as well or just want to see my opinion on the subject.
The simple answer to this question is that Python is best for writing platform independent code and algorithms in a higher level language where we want to automate tasks, analyze data, or prototype systems where the output is more important than the speed at which we get it. Whenever a software developer chooses one technology over another it is import to evaluate the trade offs of the potential solutions.
Its primary benefit to me lies in how quickly I can develop a script to do some sequence of steps. For comparison I can write a script that would make authorized API calls to a web application back end to get megabytes of metric data and would be able to use Pythons built in iterator tools or the Pandas library to comprehend that data with a days worth of development time. I’d also be able to write unit tests for the functions which parse the data using pythons standard unit testing library in a way that other Python developers would quickly be able to identify these tests and what they are testing.
This same amount of work would likely take me two times as long in Java and even more in C++ if I tried to make it class based and extensible then made the build scripts for it for Linux and windows platforms as well. However I would make this script knowing I am trading development time for latency. If this script would be kicked off as part of a nightly workflow and the assumption is that the run time is a don’t care then we would favor the speed of development.
If however we want to expose this same sequence of steps to thousands of customers through a web application front end then Python might not make as much sense.
My actual reply to this question
The original post:
For what my technical opinion is worth working at a company that revolves around extremely large scale:
literally python is the best at automating things with simple scripts that don’t need much maintenance. It’s also best for prototyping programs and machine learning research or data analysis using pandas and numpy.
Flask and Django are respectable choices for internal corporate applications or websites with hundreds to thousands of users that don’t need milisecond response times at scale.
Most websites that need to handle millions of users and transactions will be run on optimized custom c++/java spring/php variations.
Most GUI based desktop applications are also typically c++/windows forms/java based. unreal engine is c++ / minecraft is java / and some windows apps are based on WPF. Visual studio makes making desktop apps much easier than any python based technology I’ve encountered so I believe that would win in a simplistic fight.
Mobile applications will be typically made in Swift for iOS, Java for Android based apps, or cordova (html5/angular based using a web browser component); xamarin (C# microsoft based); or react native which is a Facebook based technology for cross platform applications. There are ways to make mobile apps using Python with libraries like PyMob, Py4A, and Kivy but since mobile platforms don’t ship with Python natively it needs to be bundled in your app making the size of your bundled app much larger.
And you will never see a Tesla car running python. AI needs to be extremely optimized to analyze millions of decisions and make millions of linear algebra calculations per second through various inference engines and for that you need to be as close to machine code as possible.
Python is fine for learning AI concepts but as far as actually controlling a system that peoples lives depend on Python isn’t fast enough.
For more detail into the benefits of the main coding languages and examples of what they are used for check out this article comparing the languages as different tools that a software developer has in their tool-belt for different tasks. You wouldn’t use a nail for every carpentry project just like python shouldn’t be your main focus in learning to code.
Instead, as an aspiring developer get comfortable enough with the practices of building software and learning new technology to evaluate if your next project should be built with nails or screws a mixture of the two or some new thing that just came out! Don’t get too comfortable or fixated on what you already know and be eager to learn different approaches to problems that may be easier to scale or maintain based on some new framework or library that came out that makes sense for your goals.
Say you have two software designs and one would take one month using your most comfortable tech stack and the other would take several months. But you know the one month design is going to likely create months of headaches down the road through costly refactors and maintenance efforts. As a responsible software developer you should bias towards the better long term implementation even if it means stepping away from your most comfortable coding language and technologies.
About Stefan Bradstreet
Stefan is a Senior Software Developer at Amazon with 8+ years of experience in tech. He is passionate about helping people become better coders and climbing the ranks in their careers, as well as his own, through continued learning of leadership techniques and software best practices.