Python Tops Java As World’s Most Popular Programming Language

Python Beats Java
For the first year ever, Python has topped the TIOBE list of popular programming languages, which also lists Java as having dropped to the #3 slot:
TIOBE Index

  • Source: www.tiobe.com

The numbers don’t lie, especially since they’re being reported from multiple sources using different methodologies: Python is now the world’s most popular programming language.

That’s a big deal because Java has held the top rank on most lists of programming languages for the better part of two decades. Although Java remains widely used today (and the mountains of Java code created over the past 20+ years are not going away anytime soon, read: never), it seems pretty clear that Java will be taking a back seat to Python going forward.

Die-hard Java fans (if they exist) may lament this state of affairs. But we think the programming world as a whole will welcome Python as a replacement for Java in more and more software projects. While it’s not the best language for every programming use case (what language is?), there are plenty of good reasons for Python to overtake Java as the go-to language for most developer teams.

A Brief History of Python vs. Java

It may surprise you to learn that Python, which debuted in the early 1990s, has actually been around longer than Java, which dates to 1995. Given that Python was born first, you might have expected Python to have had an edge over Java from the start in terms of popularity and adoption. But in reality, Python and Java followed different paths in their earlier years, which resulted in Java becoming much more popular early-on.

Python initially competed with another scripting language: Perl. By comparison, Perl was seen as a robust, general purpose scripting language, whereas Python was viewed as a less capable scripting solution primarily for system administrators. Python was consequently viewed as a relatively niche language that was associated with a narrow set of use cases. In addition, although Python is cross-platform, it was initially oriented toward the Unix world. It was only starting in the 2010s that Python began gaining prominence in the Windows and Microsoft ecosystems. As a result, Python was largely overlooked for decades.

When Java came along, it was intended from the start to serve as an easy-to-learn, general-purpose, cross-platform language, making it an obvious choice for a wide range of projects. Java also placed heavy emphasis on object-oriented programming, which was very trendy at the time of Java’s debut in the 1990s. The fact that Java was backed (at the time) by some of the world’s most powerful companies – Sun and later Oracle – also helped ensure its success.

From a historical perspective, it’s easy to see why Java reigned supreme for so long, whereas Python took several decades to gain prominence. Java has been in first place on the TIOBE Index for almost every year since the early 2000s, whereas Python was a distant eighth as recently as 2012. Even in 2017, Python was only the fifth-most popular language.

Why Has Python Replaced Java?

The simplest answer is also the most likely: Python has dominated as data has exploded in the enterprise. Making sense of “Big Data” is a key use case for Python with its best-in-class data analysis and Machine Learning (ML) tools that other languages struggle to compete with. And certainly all the cutting edge development work in Artificial Intelligence (AI) is being driven by Python, from self-driving cars (such as Tesla’s Autopilot) to text-to-image generators (such as DALL-E 2) to chatbots (such as Google’s LaMDA) and virtual assistants (including Alexa, Siri and Cortana). While Java is not excluded from these initiatives, it’s just not as quick and easy to work with, which can be a real liability in such a fast-moving space. 

There are also a number of programming factors that appeal to developers who are just starting to learn software development, as well as for experienced developers looking to get started with Python, including:

  • Interpreted Language – while it’s not exactly hard to compile Java into a machine-readable language BEFORE it’s executed, the fact that Python needs no compiling (i.e., it’s executed directly at runtime by its interpreter) makes creating Python programs faster and easier to manage. While interpreted languages can be slower at running code, execution speed is often less important than ease of use in the context of modern, complex coding projects.
  • Shorter Syntax – Java is a notoriously verbose language that is “full of seemingly unnecessary repetitions; lengthy, overwrought conventions; and general syntax excessiveness,” as an informit.com article points out. This means that coding in Java can be tedious and time-consuming. It also makes Java codebases larger in terms of total lines of code, which in turn makes the code harder to manage.

    By contrast, Python may not be the world’s most concise language, but it’s certainly less verbose than Java. That’s another advantage in an era when the ability to manage complex software projects is a key priority. The shorter and sweeter your code, the easier it is to manage.
  • Ecosystem, Packages, and Extensions – There are vibrant developer communities surrounding both Java and Python, but the Python community has become larger and more dynamic. There are more than 200,000 Python packages, and most are available from central repositories like the Python Package Index (PyPI). That means it’s very easy to find open source libraries and extensions for Python-based projects. It’s also easy to find documentation and collaborators.

    Java doesn’t really offer equivalent resources. There are a few major repositories, like Maven, but they are not as comprehensive or diverse as PyPI. In general, you have to scour the Internet if you’re looking for Java code to borrow for your project. This is an artifact of the software development process twenty years ago when there was a LOT more proprietary code being created. Today >80% of all code in an application’s codebase is open source software, which not only speeds development but promotes greater innovation, as well. Compared to today’s decentralized way of building software, Java’s approach feels outdated, slow and unnecessarily handicapped. 
  • Competing JDKs – Another peculiarity that emerges from Java’s history is the fact that it has competing development kits: Oracle JDK and OpenJDK. Although both JDKs do basically the same thing, developers (and their users) may run into compatibility issues based on which JDK they use – not to mention which JRE the users have installed. By comparison, there is only one version of the Python runtime, and unless users have a seriously outdated runtime installed, most Python programs will run without issue.

Does Java Still Beat Python?

On balance, the purpose of this article isn’t to say that Python always beats Java hands-down, in all use cases and contexts. Python still has certain major drawbacks that Java doesn’t, including:

  • Multithreading issues: Probably one of the most hated features of Python is the Global Interpreter Lock, or GIL. To put it simply, the GIL makes it impossible to run multiple Python threads at once in many cases. Java doesn’t have this issue, which means that multithreading on Java is easier to implement. That said, the GIL may be on its way out, but until that happens there are GIL workarounds you can use. So GIL is really more of a nuisance than a critical flaw for Python.
  • Speed: As noted above, Python code executes more slowly than Java in most cases because Python is interpreted. That’s a clear advantage for Java in use cases where speed is critical. That said, the upcoming Python 3.11 release will offer a 10–60% increase in processing speeds, which is a welcome improvement. Of course, if speed is your primary concern, you’re better off using C or C++ rather than Java or Python. In fact, many Python packages offload compute-intensive routines (such as math functions) to linked C libraries in order to take advantage of processing speed.
  • Limited mobile support: To date, Python hasn’t made as many inroads on mobile platforms as Java has. While it’s possible to use Python on mobile, it remains more geared toward PCs and servers. That said, it’s not as if Java totally dominates on mobile devices, either. It’s very popular for Android development, but less so for iOS, where Swift and Objective-C are the go-to languages.

How to Switch from Java to Python

If you’re a Java coder who has decided (like many of your colleagues) that Python is the future, making the switch from Java to Python development isn’t particularly hard even though Python has relatively little in common with Java. Some of the key differences you’ll have to wrestle with include:

  • Dynamic Language – Python is a dynamically typed language, which means that the interpreter dynamically infers the variable types, rather than declaring them upfront as with Java.
  • Syntax – Including multiline comments (since Python does not provide a multiline comment character) and formatting where there’s no getting away with ending a statement in a semicolon and using improper indentation in Python. Python code blocks must be started with a colon and ended with a new line. 
  • Object Oriented Programming – Java is designed to be a pure OOP language in which everything is a class (a template that generates instances or objects). Python supports OOP, but it can also run code in a script mode without declaring any class at all.

There are many other differences that might trip you up when you first start, such as creating arrays, making your code run more efficiently, and so on. And you’ll also want to research the many Python frameworks available to identify ones that can help you meet your development goals. But these are not monumental tasks, especially for someone already versed in programming.

The plethora of resources dedicated to teaching Python makes it all the easier to begin your journey from Java to Python. Dive Into Python 3 and Python 101 are good places to start. You might also want to check out one of the several books written specifically for Java programmers who want to learn Python, such as Igor Vishnevskiy’s Java to Python. And there are many free courses available, including Datacamp’s Introduction to Python and tutorials from Real Python.

Conclusions – Python vs Java

While it may have been reasonable at first to dismiss Python’s surging popularity relative to Java as a temporary fluke, that’s no longer the case. It has become pretty clear that Python is set to be one of the predominant programming languages for the foreseeable future. Java may not be dying, but it will probably never regain the prominence it once enjoyed.

That’s as good a reason as any for Java programmers to consider switching to Python (or, better, to learn to use both languages at the same time). Python’s certainly not better than Java in every scenario, but advantages like easier code management, a more dynamic ecosystem, and fewer runtime compatibility issues make Python a great alternative to Java in many cases.

Next steps:

Want to get started with Python? Create and install the most recent version into a virtual environment so it won’t interfere with any other languages installed on your system.

Read Similar Stories

Java vs Python

Java Versus Python: Key Programming Differences In 2021
Understand how your Java skills will help and hinder you when learning Python.
Learn more >
Python package management

Python Package Management Guide for Enterprise Developers
Learn about package management options in the Python ecosystem.
Learn More >
Python Environment Creation

How to set up your Python environment with a single command
Learn how the ActiveState Platform can automatically create a Python environment for your project, and install it into a virtual environment with a single command.
Learn More >

Recent Posts

Webinar - Walking Dead Past Python EOL
Walking Dead Past Python EOL

Stuck living with zombie applications running on Python 2, 3.7 or other past-EOL software? Learn the case for maintaining vs. upgrading, and how you can adopt a culture of getting current and staying current, with lessons from our customers.

Read More
Scroll to Top