Python is a Serious Language for Backend Development: In this article, we will talk about the attitude towards Python among developers and discuss all the main claims that have been following the language for a very long time. It is often used in leading back-end development companies (https://devoxsoftware.com/services/back-end-development-services/).
Almost everyone scolded Python for dynamic typing – this is one of the biggest complaints against it in the development environment. But is dynamic typing really that bad? At the very least, development in dynamically typed languages is easier, faster, and often more enjoyable — of course, this is a subjective thesis, but it has a right to exist.
However, dynamic typing has its downsides. For example, if we have to write more tests, we may have more runtime errors under certain conditions. We have dynamic typing, so we won’t be able to understand before launch that there is a problem with types. And it seems that static typing wins here.
At the same time, tests for business logic are not canceled by static typing, and in Python, types can now be checked statically using annotations and MyPy. Of course, we write more tests and carefully check the business logic, but, in my opinion, this is good for the services. Everything is very ambiguous.
Based on type annotations, modern frameworks are built, such as Pydantic (strict validation schemes at runtime) or FastAPI. This is what I think: Python, in conjunction with type annotations, introduces us to gradual typing and thus provides a healthy compromise between the advantages of dynamic and static typing. It does not spawn a chthonic monster, as it is often advertised on the Internet. On the contrary, we are given a way to write both quickly and reliably, here and now.
Somewhere here, the question of type safety creeps up on us. Currently, there are no type errors with MyPy and type annotations, but it is possible.
It is also worth remembering that people who prefer static typing often say that for small projects dynamic typing is “not terrible”, but on massive ones, we start to feel its disadvantages.
This aspect of the language is often criticized by very many developers. And if dynamic typing is a complex and controversial topic for discussion, then speed is what everyone is talking about.
If you look at synthetic benchmarks, you can often find Python at the very bottom of the leaderboards. Many developers consider this the Achilles’ heel of Python, which cannot but affect the perception of the language.
When discussing the speed of Python, they usually think about C++, because all benchmarks look a hundred times better on it than on Python. But if we start to understand the issue, it becomes clear that the speed of Python at this stage is not such a problem. Of course, Python is really slow in CPU-bound tasks. And then a thought arises in your head – if it is so slow, then this is definitely a problem!
Modern web development is full of i / o-bound workloads: often we receive requests over the network, send them to the network, read from the database, write to the database, operate on files, and so on.
For this type of task, Python has a great answer – asynchronous language subset, native async/await, event loop out of the box, and uvloop, for those who want even faster. With this part of Python, we can efficiently utilize CPU resources. And for exclusively CPU-bound in the world of Python, there are also many “poultices”: multiprocessing, subprocess, Pypy, Cython, Numba, and so on. Therefore, asynchronous Python is very fast.
Much can be safely written in Python, and CPU-bound, if necessary (if the standard library does not pull), rewritten in faster languages , and put these microservices-workers behind message queues. Isn’t it the perfect combination? That is why dedicated development company Devox often uses it in their work.
- August 10, 2021
- August 2, 2021