Python is Slowly Losing its Charm | by Lakeny Dakins | Nov, 2020

Image for post

Photo by Tamara Gore on Unsplash

Ever since Python was released in the early 1990s, it has generated a lot of hype. Sure, it took the programming community at least 2 decades to appreciate its existence, but since then, it has far surpassed C, C#, Java and even Javascript in popularity.

Although Python dominates the fields of Data Science and Machine Learning, and, to some extent, Scientific and Mathematical computing, it does have its share of disadvantages when compared to newer languages like Julia, Swift and Java.

One of the main driving points behind Python’s meteoric growth was how easy it was to learn and how powerful it was to use, making it extremely appealing to beginners and even those who shied away from programming because of the hard, unfamiliar syntax of languages like C/C++.

The language, at its very core, emphasised extensively on code readability. With its concise and expressive syntax, it allowed developers to express ideas and concepts without writing tons of lines code (as would be the case in lower-level languages like C or Java). Its simplicity a given, Python seamlessly integrates with other programming languages (like offloading CPU-intensive tasks to C/C++), making it an added bonus to polyglot developers.

Yet another reason for Python’s versatility is its heavy usage by enterprises (FAANG included) as well as countless smaller ventures. Today, you’ll find a Python package for pretty much anything you can think of — for scientific computing, you’ve got Numpy, Sklearn for Machine Learning and Caer (my Computer Vision package) for Computer Vision.

Image for post

Photo by Nick Abrams on Unsplash

This is probably a no-brainer. Speed is generally considered to be one of the key focuses of a developer and will probably continue to be for an unforeseeable amount of time.

Among the major reasons why Python is “slow”, it really boils down to 2 — Python is interpreted as opposed to compiled, ultimately leading to slower execution times; and the fact that it is dynamically typed (data types of variables are automatically inferred by Python during execution).

In truth, this argument that “Python is slow” tends to factor a lot among beginners. Yes, it’s true. But only partially.

Take, for example, TensorFlow, a Machine Learning library available in Python. These libraries were actually written in C++ and made available in Python, sort of forming a Python “wrapper” around the C++ implementation. The same goes for Numpy and, to an extent, even Caer.

One of the major reasons for Python’s slowness is the presence of GIL (Global Interpreter Lock) which allows only one thread to execute at a time. While this boosts the performance of single threading, it places a limitation on parallelism where developers have to implement multiprocessing programs as opposed to multi-threaded ones, to improve speeds.

When objects go out of scope, Python has automatic garbage collections. It aims to remove a lot of the complexities involved in memory management that C and C++ involve. Owing to the flexibility (or lack thereof) of specifying data types, the amount of memory Python consumes can quickly explode.

Moreover, some bugs that may go unnoticed by Python may pop up during runtimes, ultimately slowing down the development process by a considerable factor.

Image for post

Photo by Yura Fresh on Unsplash

With a large shift from desktops to smartphones, it’s obvious that more robust languages are required to build software for mobiles. While Python has a sizable representation in desktop and server platforms, it tends to lose out on mobile development owing to the lack of strong mobile computing processing.

Over the recent years, there has been a lot of advancements in this area, but these newly added libraries aren’t even close to their strong competitors like Kotlin, Swift and Java.

Recently, newer languages like Julia, Rust and Swift have popped up on the radar, borrowing a lot of the good design concepts from Python, C/C++ and Java — Rust pretty much guarantees memory safety and concurrency at runtimes, and offers first-class interoperability with WebAssembly; Swift is almost as fast as C due to its support for the LLVM Compiler Toolchain, and Julia offers asynchronous I/O for I/O intensive tasks and is blazingly fast.


More Posts

Send Us A Message