The Reasons for Python’s Popularity in 2023
Technology has become so integrated into our daily lives that many of us don’t even take notice of it anymore. For example, when you unlock your phone with your face or use it to make a purchase, you’re using more services and applications than you may realize, many of which are likely using Python.
Research by Coding Dojo found that of the top 25 US-based “unicorns”, including Instacart, Doordash, Airbnb, and even SpaceX, 20 are using Python for development. And as of November 2022, Python ranked in the number one spot in the TIOBE index.
In this article, we’ll dig into some of the reasons why Python continues to trend upward as one of the most popular and most used languages of the decade.
Table Of Contents
Why Do Companies Choose Python?
Python is a flexible, easy, and reliable programming language, and it’s no coincidence that so many startups are using it. The language is similar to plain English and is used in both back-end and front-end development.
It also has database support and the capabilities to easily create data pipelines, but these are just a few of this language’s advantages. Companies are now leveraging Python for applications that range from prototyping to high-efficiency production code and cutting-edge research.
Python’s utilization in many applications has seen exponential growth in demand and popularity in the past years. Whether you’re a seasoned developer looking for a new language to pick up or you just want to understand how companies are leveraging the language, this article will show some of the main benefits of using Python in your applications. We’ll also look at how clean a simple program is compared to Java and how to use certain popular tools to write production-quality code.
The Main Reasons Why Is Python So Popular
It’s Incredibly Easy to Learn
Python is one of the easiest programming languages to learn and use, making it a perfect choice for schools, colleges, and any place of learning. Anyone pursuing a formal education in computer science is likely to be introduced to Python and to continue using it throughout their career.
Furthermore, its simplified, elegant syntax and similarity to written English makes it so accessible that many people with a background in careers other than software development take it as a tool to help them through their research, studies and tasks.
Since Python is an interpreted language, it’s also much easier to debug. Handling the code line by line instead of through thousands of errors in the debugger shows you the exact line where the problem occurred.
It’s Driving the Trendiest Branches of IT
From AI and Machine Learning to Data Science and Engineering, Python is the go-to language for the hottest branches of IT, and as they increase in popularity, so does the language itself. We’ll explore the use of Python in these areas further down below.
The use in these areas of software development also makes Python one of the most sought-after skills, which in turn makes it one of the most well-paid languages, further increasing its popularity. According to a survey by Stack Overflow, Python developers are the 10th top paid worldwide and in the US the average salary is US$120k yearly.
It’s Super Powerful for Web Development
Another aspect driving Python’s popularity is the use in web development, which is an area that has taken over most of what used to be desktop applications and even competes with native mobile ones. While there’s no denying that JavaScript is the dominant language in the web, Python is also a popular choice for both backend and frontend applications thanks to frameworks like Django and Flask.
It has Support from Renowned Corporate Sponsors
One of the best things that can happen to a programming language is getting backed by corporate sponsors, as that indicates a strong vouch for their stability
In the case of Python, that backing comes from some of the most renowned industry giants such as Facebook, Amazon Web Services and Google.
Google has been using Python throughout their products since 2006, actively backing the language with institutional effort and lots of money to educate on the language, popularize it, and further develop both the language and the related ecosystem.
It’s Heavily Used in the Internet of Things
The days of the Internet being something just for computers and mobile devices is long gone. Nowadays it can be accessed by all sorts of devices and sensors that can connect through the internet to exchange data.
Python is becoming the language of choice for applications running in these low-processing-power devices, either through the standard version of the language or Micropython, a subset of the language specifically designed for that use case.
It Has a Big Community
Python has a vast community of developers who are constantly working on projects to improve and create new libraries. As an open-source project, it is freely usable and distributed, even for commercial use.
It’s the Swiss Army Knife of Programming
Because of Python’s flexibility, it can be used in a wide range of ways from small scripts to automate a task to creating a whole data pipeline to use in production. It’s used for back-end and front-end, applied from finance to marketing industries, data analysis, and autonomous vehicles, and it runs on Mac, Windows, Linux, Android, and iOS. As you can see, Python is the real swiss army knife of programming languages.
It Improves Productivity
With just a couple of lines of Python code and virtually no additional libraries, you can create a proof of concept for your project or quickly automate some tasks. In the next section, we are going to compare a simple script written in Java and Python to demonstrate how easy it is to prototype using Python.
It has a Python Frameworks
Python has a variety of frameworks depending on what you want to build. For web development, there’s Flask, a very light framework ideal for simple applications, and Django, a more robust framework built with microservices in mind. Other good options for frameworks include FastAPI and Pyramid. For data, there’s ScikitLearn, Apache Spark, Hadoop, Jupyter Notebook, Tensorflow, and Apache Kafka, for example.
The Disadvantages of Python
A popular and flexible language can still have its drawbacks. Although Python is fast enough for many applications, it’s slow when compared with C/C++ and so some real-time applications, like autonomous vehicles, can’t be done using Python. Python also is not memory efficient, a drawback of no variable type declaration, which could be critical in edge applications. Besides, it’s not suitable for mobile applications and is used more in back-end applications.
Comparing Python Code with Java
The best way to show the main benefits of Python is with an example. Let’s use a simple task, for instance, to read a CSV and take a look at what’s inside. Of course in a real application, you would do something with the data, like parsing and saving or transforming it, but for the sake of simplicity, this task is just to show in the terminal.
Let’s take a look in a Java code first:
1import java.io.BufferedReader;2import java.io.FileReader;3import java.util.ArrayList;4import java.util.Arrays;5import java.util.List;67public class Main {8 public static void main(String[] args) {9 List<List<String>> records = new ArrayList<>();10 try (BufferedReader br = new BufferedReader(new FileReader("C:\\\\Path\\\\to\\\\csv\\\\file\\\\test.csv"))) {11 String line;12 while ((line = br.readLine()) != null) {13 String[] values = line.split(",");14 records.add(Arrays.asList(values));15 }16 } catch (Exception e){17 System.out.println(e.toString());18 }19 System.out.println(records.toString());20 }21}2223output: [["1.0.0.0", "1.0.0.255", "AU", "Australia"], ["1.0.1.0", "1.0.3.255", "CN", "China"], ["1.0.4.0", "1.0.7.255", "AU", "Australia"], ["1.0.128.0", "1.0.255.255", "TH", "Thailand"]2425
We can see a classic Java program, with all the imports needed and the definition of the main class. Every class may have a main method, which determines the starting point of execution for any Java application. It must be a public method to allow it to run from the Java virtual machine. It has no return value but takes as an argument an array of strings that correspond to the parameters that can be passed to the application from the command line.
With this robust code in mind, now let’s use Python to do exactly the same:
1with open('path/to/file/test.csv', 'r') as csvfile:2 records = [line.split(',') for line in csvfile]3 print(records)45output: [['1.0.0.0', ' 1.0.0.255', ' AU', ' Australia '], ['1.0.1.0', ' 1.0.3.255', ' CN', ' China'], ['1.0.4.0', ' 1.0.7.255', ' AU', ' Australia'], ['1.0.128.0', ' 1.0.255.255', ' TH', ' Thailand']]67
That’s it, just three lines of Python code and no, nothing is missing. If you copy and paste in a .py file and run against your CSV, all lines should be printed on your screen.
Considering how easy it is to code and how readable it is, you should have a taste of why Python is so popular right now. As you can see, it’s almost like plain English:
“With this CSV file open, save the records splitting every line by comma, for each line in the file, and print the records.”
The list comprehension feature is one of my favorite properties in Python. You can easily append values in a list using a for loop and a condition packed in one line. Here it is the same Python code without using list comprehension:
1with open('path/to/file/test.csv', 'r') as f:2 results = []3 for line in f:4 words = line.rstrip().split(',')5 results.append(words)6 print(results)7
Five Uses of Python Programming
So far we have talked a lot about how Python programming is flexible and have gone over a number of libraries available, but let’s take a better look at where it can be applied and how it can be helpful.
1. Using Python for Data Engineering
The main objective of a Data Engineer is to prepare and move data inside an organization. Most of this is organized in what is called a data pipeline, which could look like this:
- Moving Data from Various Data Sources to the Cloud
- Cleaning Data
- Normalization and Modeling Data
- Storing Data in a Data Warehouse
- Create Analysis Using the Relational Data
And all these steps can be performed simply using Python. Libraries like Hadoop, Spark, Airflow, AWS Boto3, Pandas, SQLAlchemy, and even pure Python sometimes, help developers to achieve such goals.
2. Using Python for Data Science
Python really excels beyond other languages in Data Science. Jupyter Notebooks is an easy and intuitive, open-source web application that allows users to execute the code line by line visualizing the results right away. Tools like this, paired together with Tensorflow, Pytorch, and ScikitLearn have served as a propeller for the wide adoption of Artificial Intelligence. Python also offers a big range of beautiful and interactive visualization libraries such as Matplotlib, Seaborn, Plotly, Bokeh, etc. Compared to competitors like Matlab and R, Python offers a much more dynamic and easy-to-use environment.
3. Using Python for Software and Web Development
As stated before, Python is used in both backend and frontend applications and relies on frameworks like Django and Flask for web development. There are also standard libraries like HTML, JSON, email processing, and FTP to support internet protocols. For software development, Python programming is predominantly used for its process control capabilities, but it’s also present in testing tools and desktop GUIs development.
4. Using Python for Research
Over the years, Python has become a popular language for scientists as well. It has significant scientific and numeric libraries and has been used in many research institutions as well as in the academic sector. Libraries in the SciPy ecosystem such as Numpy, Pandas, and the aforementioned Jupyter, have been helping researchers push the borders of the scientific community. Since some of these packages are based in C/C++ and expose functions using Cython, Python is fast enough for big scientific analysis.
5. Other Applications
We’ve covered some of the main applications that use Python, however, this doesn’t mean you’re limited to these projects. In fact, Python projects are everywhere. You can automate tasks in your OS with native libraries, process images with OpenCV, create finance analysis and reports, and you can also use Python for game functionalities and add-ons. Do you know that the games Battlefield and Pirates of the Caribbean have content written in Python? Even journalists are using Python to crush data and retrieve better insights.
Python Development Tools for Better Production Code
With such a wide spectrum of applications, let’s look at some Python development tools that can help you in any project. When we are prototyping or creating a proof of concept, we skip several steps for writing good-quality code. Only when the program is heading to the production system do we consider how to make it clearer and more readable. This production-quality code should be efficient and easy to understand, with no throwing errors, and robust to users’ inputs and data types. Moreover, the code must be readable and well-documented in order for anyone to understand and improve it. The following tools will help you to write better production code.
Style Guide PEP8 with Flake8
If you’re familiar with the language, you likely know about PEP8, a document that provides guidelines and best practices for Python developers. This will help you improve the readability and consistency of your Python code. Instead of doing it all by yourself while reading the document, flake8 will check your code against the guidelines, check for programming errors, and even its complexity.
Docstrings in Python
Similar to comments in your code, documentation strings serve to explain how functions, classes, and methods work. It helps other people to better understand the inputs and outputs of your code in a convenient way. In softwares like Pycharm and Visual Studio, there are extensions to auto-generate docstrings in your Python code. It also has a standard library called PyDoc, which generates web pages for your code. Speaking of documentation, this leads us to the next topic…
Documentation with Sphinx
The most boring part of writing good code is to document and publish the project so everyone understands how to use it. Based on reStructured text, Sphinx is a tool developed to create great documentation in an easy way. It has several output formats such as HTML, LaTeX, ePub, etc. After setting it up and pointing to your project folder, you can generate the documentation by simply typing “make html” on your terminal. Make sure to have used the docstrings!
Unit Tests in Python with Unittest
Testing your application before deploying is a must these days. Sometimes it’s impressive how unexpected an input can be and the effects it may have on your code. There are several types of tests, but a good start is to unit test bytesting just one component of your Python code to ensure it behaves the way you design it. Unittest is a standard python library that allows you to put your tests into classes as methods and test your code against several possible situations.
Pre-Commit Hooks with Pre-Commit Package
As a last measure to ensure that you have utilized the tools, you can use the pre-commit hooks. Git has a way to fire custom scripts once an action is made, such as committing or merging. Git Hooks are divided between client and server-side, and a good way to start is using the most basic client-side hook: pre-commit hooks. This kind of hook is fired before the commit and its job is to check for tests, code style, documentation, or if you forgot something. Python has a package called pre-commit that creates hooks automatically and is an essential tool to keep a standard in your repository and ensure readability and clean code.
Final Thoughts
It’s not too late to start using Python in your organization. The growing community, the number of new applications, and the maintenance of existing ones will keep the language alive for a long time. As we’ve explored in this article, Python has as many benefits for developers as for companies. From helping to prototype and interfacing databases, to back/front-end applications and creating readable code, it has many capabilities.
I’ve been programming since 2010 and since then I’ve become a big fan of Python and how versatile it is. I use it daily in a variety of ways, from small tasks to building an end-to-end Artificial Intelligence project. Even though it wasn’t my first programming language, it’s one that I continue to work on even after learning as it allows me to put my ideas into real-world applications. The upsides still outweigh the downsides for many applications and its readability makes things even easier to review and share code.
Python has proven to be a reliable programming language over the years. This language has reached a whole spectrum of programmers from big tech companies like Google to developers just starting out with programming. Regardless of where you are in your development journey, you can benefit from migrating or creating new features in Python.