What are some things one may dislike about Python?


In this article, we will look at some of the things that most people dislike about Python.

Using Indentation Instead of Curly Braces

Many people complain that Python fully relies on indentation to build code blocks. In Python, as you may know, indentation is not optional. The complaints vary, but they frequently include one or more of the following.

It is Difficult to Tell Where a Function Ends

That is true when writing large Python functions. However, it would be advantageous if you avoided writing large functions altogether. This is true for any language, not just Python. A function should only do one thing well. If you find yourself developing a multi−page function, break it up into smaller functions that only do one thing.

This produces more than just clean, legible code. It also produces testable code. Unit tests for short functions that accomplish only one thing with no side effects are simple to write. When you develop huge functions that do a lot of things, you can only write integration tests.

Several Python Versions

We have seen users dislike Python because it has two versions− Python 2 and Python 3.

To make this situation worse, they are frequently installed beside one another on Linux. Although both were formerly prevalent (and incompatible), this is far less of an issue today than it was.

Most projects have now migrated their code to Python 3, however, this was not always the case. Unfortunately, because so many packages took their time to make sure to convert to Python 3, many Linux distributions have been driven to ship with two versions of Python.

To sum up−yes, it was a true point for a few years during the Python 3 transition, but it's largely resolved now.

Python is Slow

Here's another reason people dislike Python. Python was not intended to be the fastest language in the world. There's also the Python GIL, which isn't nearly as bad as people make it out to be.

In fact, Python as a language prioritizes understandable, clean code over mere speed. So, no, Python is not the quickest language. Yet, We find many people complaining about it without actually having a speed issue, or at least without first attempting to fix their own inefficient code.

If you have a speed issue in Python, there are several things you can do to speed up your code. One of them is using concurrency. However, most of the time, it is simply a matter of optimizing your code.

You can look into the following −

  • Caching

  • Bloom filters

  • Use of appropriate data structures

  • Minimize the amount of work you do inside loops

  • Prevent recursion.

Alternatively, consider speedier Python implementations such as PyPy and CPython. As if that weren't enough, several of the most popular Python programs, such as NumPy, have their essential functionality implemented in C. As a result, replacing your code with functionality from libraries here and there may produce better outcomes.

Python Does Not Scale Well for Large Projects

In debates, Many People heard individuals defend Python only to conclude that it's a scripting language that doesn't scale well into larger projects. And it's just not true. But People are aware of several huge applications that are running smoothly. In fact, Python includes all of the necessary tools for scaling −

  • If you like, you can divide the project into different packages.

  • Modules can be used.

  • It allows for object−oriented programming.

Python scales just as well, if not better, than any other language. Home Assistant is a large project that I use every day and night in my home. It demonstrates that Python can be used to create huge, complex applications.

Python is Just a Typeless Scripting Language

This is partially true and partially false. Python is an excellent programming language. It allows us to quickly put together a script to accomplish specific tasks without having to define types explicitly beforehand. It enables us to prototype and does quick tests.

This type of typing flexibility is known as dynamic typing. The variable lacks a type, yet the object you create does. Aside from that, Python is a strongly typed language, which means that once an object is created, its type will not change.

The string "2," for example, will not suddenly transform into a number when used in an equation like "2" + 2. If you do, Python will throw a TypeError.

Python now provides a great hybrid model with the inclusion of explicit type support. They appear to have found the sweet spot. Leave out the typing if you're hacking away. When writing apps, though, you can (and should) specify types. The interpreter will ignore them, but your linter and/or IDE can use them to catch potential issues. Even better, because it now knows the types of all your objects, your IDE will provide excellent auto−completion.

Even better, because it now knows the types of all your objects, your IDE will provide excellent auto−completion.

The Python community appears to have accepted the new explicit typing. FastAPI, a popular API framework, uses typing extensively. It's one of the reasons it's so simple to use−because to explicit typing, you get excellent auto−completion in your Python IDE as well.

Python Includes Some Ugly Global Functions

There are no global functions in object−oriented languages such as Java. In Python, examples of such functions are len() and print().

The most common issue We hear about len() is that the length should be part of the object, not a global function.

Why, for example, is there no length() method to retrieve the length of a Python list?

inputList = [4, 6, 2, 1] # This will NOT work inputList.length() # Also this will NOT work inputList.length # You must use this one len() - #4 len(inputList)

However, there are reasons why Python has the len() function instead. It's actually a deliberate design choice.

In other languages (Java, for example), the length can be obtained by calling a method on the object. But which method is it? Is it −

  • .length()

  • .size()

  • numItems()

  • …etc

Is it a variable, such as .length or .size? As a Java developer, I've seen all of these and more variations. Standardizing such a common activity makes sense. The len() function will work if your Python object implements the __len__() dunder method. All you have to do is get used to it.

Conclusion

In this article, we learned about seven things that many people dislike about the Python programming language.

Updated on: 26-Dec-2022

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements