今日推薦開源項目:《設備同步 FnSync》
今日推薦英文原文:《The Slowest Modern Programming Languages》
今日推薦開源項目:《設備同步 FnSync》傳送門:項目鏈接
推薦理由:FnSync 是手機和電腦的同步工具,能夠同步手機通知至電腦,同步剪切板,具有文件管理和傳輸功能,還可以通過手機控制電腦鎖屏,通過拔掉手機充電電源,就能立即鎖定電腦。
今日推薦英文原文:《The Slowest Modern Programming Languages》作者:Mohammed Ayar
原文鏈接:https://medium.com/better-programming/the-slowest-modern-programming-languages-d29ea2306675
推薦理由:解釋型編程語言通常比編譯型要慢,但是當然不意味著沒有競爭力。本文列舉了5種最慢的編程語言,它們有各自的特點和「慢」的理由。
The Slowest Modern Programming Languages
And the reasons as to why they are slow
(Photo by Karl Ibri on Unsplash)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:
(Moore』s law. Source: Wikimedia)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 5 relatively slowest common dynamically-typed programming languages.
Perl
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
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:
(Source: StackOverflow 2020 survey.)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.
Ruby
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.
Python
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.
Takeaway
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.
(Source: Twitter)Ultimately, despite dynamically-typed languages being slow they provide promising language experience as well as pump up productivity. So, coding is never boring.
下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/