Python menettää hitaasti viehätyksensä

Original article was published by Regadermawan on Artificial Intelligence on Medium


Python menettää hitaasti viehätyksensä

English Version

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.

What made Python so popular?

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 for Computer Vision.

Python’s Got Weaknesses

It’s slow, terribly slow

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.

It’s got a GIL(l)

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.

Not the best for memory-intensive tasks

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.

Weak Presence in Mobile Computing

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.

The Rise of Other Languages

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.

Conclusion

Python was never built to be the best programming language. It was never built to take on C/C++ and Java. It was built to be a general-purpose programming language that emphasised on human-readable, English-centered syntax that allowed for the quick development of programs and applications.

Python, like every other language at the end of the day, is a tool. Sometimes, it is the best tool. Sometimes it’s not. Most often, it’s “just okay”.

So, is Python as a programming language, dying?

I hardly think so.

Is it losing its charm?

Ah, maybe just a bit. Just a bit.