PC monitor with python code on the screen
Outlier Articles Home

Computer Science

Why Is Python So Popular Among Programmers?

07.11.2023 • 7 min read

Erin Rachael Hoffman

Udacity Data Scientist & Outlier Lecturer

Learn what Python is and why it’s popular. Also read the uses and applications of this programming language in the tech industry.

In This Article

  1. Python at a Programming Glance

  2. 8 Top Reasons Why Python Is Popular

  3. Python Use Case Examples

  4. More About Python With Outlier.org

Python at a Programming Glance

Python is getting a lot of buzz these days. According to the 2022 StackOverflow Developer Survey of people who are learning to code, Python is the third most popular language overall and the most popular backend programming language. But why is it so popular?

With 12 years of experience in programming with Python, I can confidently tell you that its popularity is well-deserved. Let’s dive into the key reasons behind Python’s widespread adoption.

Graph showing Python as the third most popular programming language

Source: StackOverflow

1. Python Is Easy to Learn

You have probably heard this before. But why exactly is Python so easy to learn compared with other programming languages?

The 3 main reasons are ‌Python:

  1. Is readable

  2. Is an interpreted language (rather than a compiled language)

  3. Fails fast (instead of failing slowly)

2. Python Is Readable

The guiding principles of Python’s design, as described in the Zen of Python, specifically state that “Readability counts.”

One key way ‌readability is encouraged in Python is: “There should be one—and preferably only one—obvious way to do it.” Other languages like R and Ruby often offer several different syntax options for performing the same task.

This can be challenging for people learning to code because:

  • It adds to the number of choices that need to be made

  • It means that 2 very similar pieces of code might superficially look very different

The fewer extra options, the easier it is to read and understand documentation or someone else’s code.

Reading code is essential for learning to write code!

Another way is that Python uses intuitive English-language names for its constructs. For example, Python calls an ordered collection of objects a list, whereas many other programming languages use the term array. Both of these are English words ‌were used before the invention of computer programming, but “list” has consistently been more mainstream.

Google Books Ngram Viewer, an example of using array and list

Source: Google Books Ngram Viewer

3. Python Is Interpreted

Python is an interpreted language. This means ‌the code is executed line by line rather than being compiled into an executable. This is great for beginners since it means ‌you can test out each line of code as you write it. You have a better understanding of what is happening and how your code is translating into the context of your application.

4. Python Fails Fast

It might seem strange to say that a language is easy to learn because it “fails”—whether or not that failure is fast. But a core aspect of learning to code is making mistakes and being able to identify and fix them! If your code is going to fail one way or another, it’s much better that the failure is fast and obvious rather than being slow and subtle.

Compared to compiled languages, Python fails a bit more slowly, but Python fails faster than other interpreted languages like Ruby and JavaScript. A great example of this is what happens when you use a Python dictionary.

A dictionary is a data structure that links keys to values. When you specify a key, the dictionary returns a value. For example, a dictionary key might be the name of a product, and the associated value might be the price.

In Python, if you try to retrieve the value for a key and that key is not one of the available keys in the dictionary, you get an error immediately.

Example of a retrieving the value for a key and that key is not one of the available keys in a Python dictionary

If you do the same ‌in JavaScript or Ruby, rather than producing an error the dictionary will return undefined or nil respectively. Those are both variable types intended to mean “nothing” or “empty”.

That might seem like a friendlier thing to do, but what happens if you try to apply a discount to the price?

In Ruby, you would get an error at that point. It’d be something like “undefined method `-' for nil:NilClass (NoMethodError)” because you are trying to subtract from a nil value, which is not a valid command.

But instead of the error coming from the line where you used an invalid key, the error comes from the line where you tried to apply the discount. Even though it’s ‌delayed by one step, this could make the error ‌more challenging to locate and resolve since those steps could be separated by multiple lines of code or even split between multiple code files.

In JavaScript, you still wouldn’t get an error—instead you would get NaN! This is yet another type of variable used to represent invalid values that mean “not a number”. Eventually you might try to use the NaN in a way that produces an error. But you also might never trigger an error and end up accidentally displaying the NaN as your final lookup result.

That kind of failure relies on users to report the incorrect value and is even harder to track down.

5. Python Has an Active Open-Source Community

The Python language itself is an open-source project—you can see all of the source code on GitHub! This open-source license means that developers around the world are free to use Python to build their own open-source projects. Over 400,000 Python packages have been published to the Python Package Index and more are being released every day.

Python packages mean that Python programmers don’t need to “reinvent the wheel” when performing common tasks. Instead of building ‌from scratch, Python programmers can accelerate their development process by installing and importing specialized packages for web development, data science, and more.

Import antigravity” even exists. It’s a running joke in the Python community about how it’s ‌so easy to import powerful functionality that you could probably ‌import something that would let you float up in the air.

6. Python Is Fast

You might be scratching your head at this one. Isn’t the Python programming language notoriously slow compared to compiled languages like C and Java?

Well, in a head-to-head comparison performing identical tasks, Python is slower than those languages. However Python can still be ‌fast because of the open-source packages mentioned above!

For example, the NumPy numerical computing library allows developers to write code in Python that is then sent to already-compiled C and Fortran code. This has accelerated the pace of scientific progress, from the first image of a black hole to the discovery of gravitational waves.

Another great example is PySpark, a Python interface to the Apache Spark data analytics engine. Spark is one of the most popular tools for Big Data and typically requires that commands be written in Java or Scala, but PySpark makes it accessible for Python developers as well.

In traditional academic contexts, the same individuals need to act as both researchers and teachers. This can introduce some tension, because the skills needed to perform research tasks and teaching tasks often differ.

Luckily Python tooling tends to be useful for both contexts. Academics can seamlessly transition between using Python to perform scientific experiments and using Python to teach classes. This overlap has meant that Python is increasingly the language of choice in academic institutions.

8. Python Is Used By Top Tech Companies

Popularity can be self-perpetuating! As more people use Python, the incentives keep growing to adopt Python technology stacks.

Many industry leaders use Python. A few famous examples are:

  • Dropbox

  • Spotify

  • Netflix

  • Facebook

  • Uber

Some companies have even become Python Software Foundation sponsors so that they can actively influence the direction of the language and ensure its ongoing maintenance and success.

Some examples are:

  • Google

  • Microsoft

  • Salesforce

  • AWS (Amazon Web Services)

  • Verizon

This sponsorship shows that these companies are invested in Python for the long term.

Python Use Case Examples

Python is a general-purpose language, but there are a few specific areas where it really shines: web development, DevOps, data science, and machine learning.

Web Development

Python is commonly used to develop the backend for web applications. This is the software that runs constantly on a web server, waiting for incoming requests.

When it receives a request—for example, if someone has entered the relevant URL into a browser address bar—it retrieves the relevant data and serves website source code—HTML, CSS, and JavaScript—back to the browser.

This type of application would be challenging to implement from scratch. But with Python web development frameworks and Python language features—like decorators—they can be quick and easy to build in a few lines of code.

Web development frameworks listed on the official Python wiki include:

  • Django

  • Flask

  • Dash

  • FastAPI

DevOps

DevOps—short for “development operations”—means preparing and automating the tooling needed for software development and deployment. Python is a useful tool for DevOps work because it has great support for scripting automation and infrastructure maintenance.

In a broader context than just DevOps, Python is one of the best languages for a cloud developer because it has great support on AWS.

Data Science

Data science is my favorite thing to do with Python! Data science means combining scientific techniques with data analysis techniques to find insights.

Many great Python packages exist like:

  • pandas for performing data cleaning

  • SciPy for performing statistical analyses

  • NLTK for performing natural language processing

  • Matplotlib for creating data visualizations

(I actually used all 4 of these as part of my analysis in writing a published paper.)

Beyond the packages for specific data-related tasks, the scientific Python community has built some excellent tools for writing code in Python. The Jupyter Notebook is a great example—it integrates Python code and Markdown documentation in a web application that can be run in the browser from anywhere.

Organizations like Cookiecutter Data Science have also been working on developing standards for creating reproducible scientific analyses with Jupyter Notebooks.

Machine Learning

Machine learning—also called “artificial intelligence—means applying data science techniques to “learn” from past data in order to make predictions, gain insights, and even generate innovative content. Python is a popular language for both traditional machine learning techniques like linear regression as well as cutting-edge deep learning techniques like neural networks.

Python libraries for traditional machine learning include:

  • Statsmodels, with modules for linear models, imputation, and time series analysis

  • Scikit-learn, with modules for nearest-neighbors models, tree-based models (e.g RandomForestClassifier), and gradient boosting models

And Python libraries for deep learning include:

  • TensorFlow

  • PyTorch

  • fastai

  • Hugging Face

  • OpenAI (creator of ChatGPT)

More About Python With Outlier.org

The Outlier Applied Computing program is a great way to get started with programming, stats, and more. Outlier is an affordable alternative to traditional college courses. Outlier courses are flexible, are taught 100% online, and confer 3-4 transferable credits each.

In the first term you’ll get started with Java programming in Computer Science I—where, by the way, I’ll be one of your instructors! Then with the career certificates you’ll learn how to apply Python to data analytics, backend web development, or IT support.

Degrees+: Discover Online College Unlike Anything You’ve Experienced

Outlier (winner of TIME Best Inventions 2020) and Golden Gate University (#1 school for working professionals) have redesigned the experience of earning a college degree to minimize cost and maximize outcomes. Explore a revolutionary way to earn your college degree:

Share