Where is Python in the Race
Far Behind, if code execution speed is considered a major factor but if your application does not need to be very fast (like a chatbot where a time difference of a few milliseconds does not matter), Python is eons ahead of most other languages. But why is Python so slow? Let’s steal a peek at some of the factors that make Python a slow language.
- Python is a Dynamically Typed Language – At the time of execution, the Python Interpreter is unaware of the type of variables it is dealing with. So every time an operation is performed on the variable, memory is assigned to it dynamically on the go depending on the data type. Whereas in Statically typed programming languages, the interpreter knows the type and thus the memory space required for most operations in the execution thread.
- Python is not exactly a ‘Complied’ Language – The term ‘Compiled’ for Python is highly debatable and you can easily find arguments for and against it. However, one thing’s for certain, Python lacks a smart compiler that can look ahead into the code and optimize for redundant operations.
- Function Call Overhead – The time taken to call a function in Python is relatively high as compared to some other languages.
Reasons Why Python is Loved
And despite several shortcomings of its own, the 2018 StackOverflow Developer Survey declared Python as the 3rd most loved language after Rust and Kotlin. It also showed Python as the clear title bearer of the ‘Most Wanted Language of the Year’. Here are some of the reasons why Python is currently in the limelight amongst all its competitors.
Here’s the code for the classic first ‘Hello World’ Program in Python.
It really is as easy as that. Python works with the least bit of code possible and lets the developer focus on learning actual programming concepts instead of the workarounds of the language itself.
Python is highly modular in nature. For those of you who don’t understand what I just write, modular programming is the process of subdividing a computer program into separate sub-programs. A module is a separate software component. It can often be used in a variety of applications and functions with other components of the system. You can create and use your own module in Python quite easily.
Extensible in C, C++
For the programming needs where speed and memory management is the priority, Python allows modules to be included in C and C++.
Vast Support Libraries
Python comes with highly efficient support libraries in areas like Web Services, Application Development, Strings, Operating Systems etc.
What..? You can find various articles claiming that it is not Productive. Well, it depends on what is your take on it. I think getting the job done is Productivity and by my take, it is productive. But some might say what about speed optimization?
First get the job done and then think about optimization. “Premature optimization” is essentially the root of all evil because you are wasting your time way too much on the speed optimization which is going to save like-may be a couple of nanoseconds or microseconds. So, you decide whether it is productive or not.
That’s it for this article. I hope that this article, answers your questions well enough. Do comment your feedback, your questions and do check out other articles as well.