The Slowest Modern Programming Languages
Programming languages have been out there for decades. Each language is built to satisfy a certain need.
As of today, the world counts about 700 notable programming languages. While about 250 managed to stay afloat, the rest was dumped by the programming community. (Latest data from Wikipedia)
Performance has been always an alarming matter for programmers. While before, execution time could be measured in calendars, nowadays, it is measured in fractions of seconds. Credits go to advancements in electronics.
The speed rate by which computers evolve follows Moore’s law:
In electronics, speed and performance translate to the number of transistors a particular chip can have. The number surprisingly doubles every two years according to Moore’s law. That’s why your hand-sized mobile phone is way faster than a room-sized supercomputer of the 1990s.
When it comes to computer science, there is a difference between a faster code and a faster PC. A slow program and a slow computer.
I bet our friends at Intel and AMD are doing a great job creating powerful computing systems in terms of speed. Creating robust and fast programs is, therefore, up to us.
One of the things to take into account while creating software is language expectations. Each language is implemented differently, so each one delivers on its proper merits. And speed might simply not be among these merits.
Now, if you’re trying to build a program that would carry out demanding tasks such as games and heavy mathematical computations, you’d better steer clear from slow programming languages.
Generally, programming languages are two types:
- Statically-typed programming languages
- Dynamically-typed programming languages
Statically-typed languages are usually compiled, meaning a program called the compiler parses and converts your entire English-like code to assembly language and produces a new file. This file, in turn, is executed manually by the user.
Dynamically-typed languages are usually interpreted, meaning a software — the interpreter — analyzes and runs the code in a line-by-line fashion.
The particulars of compilers and interpreters are heavily academic and therefore beyond the scope of this article.
Most of us like dynamically-typed languages. The languages that are less error-prone and interpreted easily by the human such as Python. But this comes at a cost. Speed.
In this post, we will lay down the relatively slowest common dynamically-typed programming languages.
If you used UNIX before, it is highly unlikely that you haven’t seen a Perl script. The majority of UNIX files are in Perl.
Perl is a Unix scripting language. It was created to mitigate the hardship programmers have to endure coding lengthy Shell programs. It is simply a bunch of Shell commands stuffed into a file.
More importantly, Perl came to ease the tasks that were considered a nightmare to accomplish in C and the other Unix languages. Of course, C wouldn't accept to be overtaken without paying the price.
As it was, Perl was taxed speed wise.
Additionally, finding a great Perl programmer these days is like trying to find a needle in a haystack. This is because, unlike Python, for instance, Perl is pretty sensitive to implementations and every operator should be in the right place to have a relatively efficient program.
Even with the most efficient implementations, Perl still stumbles behind its high-level programming languages counterparts. Yet, it’s still growing and efficiency problems are being solved one after one especially after Perl 6 release in 2019, which was named Raku.
PHP is a scripting web development programming language and usually complements HTML, CSS, and MySQL in website deployment.
Many argue that PHP is obsolete. But the truth is: IT IS NOT!
w3techs said :
“PHP is used by 79.0% of all the websites whose server-side programming language we know.”
On top of that, the recent 2020 StackOverflow survey on programming, scripting, and markup languages showcased PHP as a perfectly alive language toping both C++ and Typescript:
However, Because PHP has a gradual learning curve and cheap to host, it takes damages in terms of performance.
PHP is incredibly slow because of the lack of just-in-time compilation (JIT compiler) and the fact that it is a dynamically-typed language. Fortunately, on November 26, 2020, PHP 8 came out with a performance optimization feature: a built-in JIT compiler.
The built-in JIT compiler helped PHP draw nearer to the programming languages of its class in terms of speed and performance.
Yukihiro Matsumoto, the official author of Ruby and known as Matz in the Ruby community, said:
“Ruby is designed to make programmers happy”
Ruby is an objected-oriented programming language. Everything is interpreted as an object. This has made it an elegant and easy tool to work with. Wave the wand and, your task is completed.
However, in terms of performance, Ruby is a typically interpreted language. Because interpreted languages run the code statement by statement, they tend to be slower compared to languages that use compilers.
Ruby takes another hit in terms of speed from the Global Interpreter Lock (GIL). This means that the language allows one thread at a time to use the GIL.
Lastly, Ruby also suffers from high memory consumption and slow garbage collection.
The versatile Python has recently ranked 1st as the most popular programming language according to multiple sources such as statista and The Economist. It is heavily used in data science, web development, and cybersecurity.
Needless to flatter Python on this occasion as its benefits clearly outweigh its drawbacks. But as things stand now, most Pythonistas are allergic to speed. Yes, Python, unfortunately, is haunted by speed.
Python and Ruby are members of the same family. They are both slow because of the GIL and the fact of using an interpreter. The main difference between these two is that the former is data science-oriented while the latter leans more towards web development.
However, Python is backed by its powerful libraries and functions. And some of these libraries and functions, like the
Numpy module and
Filter() built-in function, are implemented in C++ resulting in a significant boost in terms of performance. That’s why Python is booming these days overtaking its fellow programming languages.
While speed and performance are important factors to take into account when it comes to software implementation, the blame should not be put on the programming languages alone.
Indeed, the root cause of major speed and performance issues is poor implementations and bad code design.
Ultimately, despite dynamically-typed languages being slow they provide promising language experience as well as pump up productivity. So, coding is never boring.