Java vs Python

I’ve been asked to compare Python to Java quite a few times now, far more often than other combinations of languages. While most of these questions came from trolls, some of them were sincere. In one instance, business decisions were made based on my recommendation.

Comparing tools

If anything can get the trolls aroused, it’s a Language A vs Language B discussion. Some people derive their identity from the tools they use. Whenever someone points out a weakness in their tool of choice, they somehow perceive this as an attack on their personality. Some respond defensively leading to wars concerning editors, programming languages, operating systems or even woordworking handtools. Sometimes these discussion are very civil, but we’ve all seen the ugly flame wars when they aren’t. When you think of it, it’s not surprising that people identify with their tools. Most of them spent literally thousands of hours of their lives practicing their skills. Many have spend more waking hours with their tools than with their significant other.

Even with the prospect of becoming flame war ammunition, I’ll try to do a comparison of Java and Python.

Comparing Programming languages

There are several metrics by which you can objectively assess the value of programming languages, such as conciseness, speed of execution, memory requirements, speed of development, tool availability, community size and portability. As second class of metrics is a bit more subjective, like readability, error-proneness and auditability.

But these metrics are not sufficient to promote one language to “the chosen one”. In this article I will focus on Java and Python. Both languages score similarly in the objective metrics, and both have a loyal following, suggesting the subjective scores are good as well. These metrics might be useful for some selection, but they leave us hanging for the Python vs Java decision.

Let’s look at this differently. What does your team look like? What’s your senior vs junior ratio? Are you actively mentoring your juniors? How’s your continuous integration? The answers to those questions characterize your team.

Java

Java is designed to prevent coding errors. It allow for very explicit interface definition, a trait which tends to be amplified by Java teams. A Java team focuses on getting things right. Modules are designed to have low coupling, and may even live in separate code bases. In the ideal Java world, refactoring one module will not require changes in other modules.

While the Java team has proper CI set up, it’s mostly there to provide evidence of good quality, not to enforce it. A Java team lacking in tests and CI may still produce reasonable code, as the language itself is designed to prevent most common mistakes.

Mentoring is very important in the Java team, as juniors grow in seniority by being guided through challenging tasks. A Java team spends a lot of resources to prevent errors, a strategy which both calls for and allows for a more rigid team structure.

Python

Python is a language that favors getting things done over getting things right. While code bases are usually divided into modules, these modules are tightly coupled. Any non-trivial change will typically touch multiple modules.

A typical Python team accepts errors as a byproduct of their productivity. More than most other teams, the Python team relies mostly on CI to make sure their code is high quality. A Python team lacking in tests or CI will produce rubbish code.

In a Python team, juniors and seniors do the same work, just at different scale. Juniors graduate to seniors by succeeding a somewhat larger tasks. A Python team accepts errors but minimizes their impact. This allows for a more eccentric team.

Which is should I pick?

Which is right? Well, as you may have guessed by now, that will depend. When choosing a language to learn, you may want to pick Python if you feel empowered by freedom or pick Java when you feel empowered by structure. Are your choosing a language for your next project? Pick Java when you need predictable productivity, pick Python when you need agility.

Do you need a language to bash? Try Malbolge.

Back To Home