Logo
    Which programming language is the fastest?
    • news
    • -
    • Which programming language is the fastest?

    Which programming language is the fastest?

    Which programming language is the fastest?The 10 most popular GitHub languages to perform comparable tasks in are now in shranki. Let's get to know the participants: JavaScript, Java, Python, Ruby, PHP, C++, C#, C, go, swift. Swift got a wild card, due to the fact that Objective-C goes to the Lamus. At first glance, it seems that C and C ++ will declass the competition. Go, JavaScript (since the inception of V8) and Swift are fairly commonly considered to be fast. We're about to find out what she's like...

    ... True

    That's right! What is the truth? Such that it is difficult to establish an unambiguous answer to this question, because as in the case of engineering-it depends. It depends on what type of operations the test is measuring, it depends on the implementation being tested, and despite the art-like operation, this result will still be far from what we will see in the actual application. The desire to know the speed of the actual application is also largely a hoax, there much depends on the database or even on the architecture of the application. In addition, in the real world, the CPU rarely limits the speed of the program, more often we will have to deal with problems with I / O. hence it follows that the comparison must be synthetic in order to isolate as many factors as possible and as simple as possible, so as not to get lost in problems with the architecture.

    With help comes”the computer language Benchmarks game". This project has been running intermittently since 2002. It involves implementing the same simple tasks in different programming languages and firing them on the same hardware. Not only are languages fighting, but implementations are also fighting. Of course, such a comparison of speeds with each other is not ideal, but the available data can be developed in an interesting way. There is also interesting additional information that can be read on the project page-about the correct measurement of execution time, about the fact that the execution time of a program in Java or Javascript in a synthetic test will be slightly different than in a larger, loaded application. I recommend reading!

    Our 10 languages will be compared using 9 benchmarks. The task execution time itself is of little interest, as it does not provide a reference. Therefore, to better show how a given result is to the rest of the languages divide the time that a given language received by the best time for this benchmark in general. On the graph, on the other hand, I carry 3 data - best relative score, worst relative score and geometric mean.

    Let the data speak

    Which programming language is the fastest?

    On the first two positions without surprises. C overtook C++. It was predictable, after all C from this group is relatively close to machine code and will perform the least operations, hence the speed (yes, simplification, it's more about the fact that it is easier to get than in higher-level languages). C++ on measured tests is about 45% slower than C-but this number is mainly projected low score in the regular expression test, where C ++ was as much as 11x slower than C. C ++ used the regular expression library of Boost a c pcre, so how much this particular benchmark measures the language's capabilities is somewhat debatable. If you reject this result, it turns out that C was only 10% faster.

    On the 3rd place of the podium - Java. Yes, the same language that is accused of being free. Who among us did not use some strange Java API that answered in good winds after a second? This dissonance between the benchmark and reality clearly shows that the most important thing is how you use the language and even the fastest of them will not save you if you do not take into account the problems with i/o and apply algorithms with complexity not suitable for the amount of data processed. And returning to the advantages of Java, this 3rd place was won mainly by the fact that none of the 9 tests found a weak point. The worst result is 8.5 x slower than C for the regular expression benchmark. In total, it turned out to be only 2.7 times slower than C.

    Another place is the latest language in this compilation - Swift, introduced by Apple in 2014. As you can see, the development of the language is going great. By the way, it is much better than Objective-C, it is very fast. Only 2.95 x the result of C. This is another language that had a problem with regular expressions, if you remove them from the list it he'd probably end up on the podium.. Swift's speed can be useful in the context of the fact that it can be run not only on iOS, but also on other platforms. There are numerous attempts to write backend applications in this language.

    Half-rate reporting C#. Microsoft's language scored 3.1 times worse than C, but in many benchmarks it showed equal form-getting times between 2 and 3 times the best result. True, the biggest competitor - Java-beat him, but C# was only 15 slower than her%. This is a difference that in the real world can be easily bridged.

    Place 6 belongs to Go. It's so interesting that I expected this language above, especially since one of the selling points of it is speed. His result is 3.25 times the time of the tests in C. go would have a chance in the fight for the podium if not for poor results in the problem with binary trees and regular expressions. In the world of real development, Golang's situation looks so much better that he focuses on simplicity and light multi-threading. Both features are a very strong asset for developers.

    Next is JavaScript (it is worth adding that under the form node.js). Here. you can already see a big drop in formbecause for our 9 tests it is more than 2x slower than go, which is in the previous place. The difference with C is 7.7 x.what is interesting-even though it is several times slower than C, JavaScript is still considered a fast backend language. I'll explain why.

    Place 3 from the end of this list took PHP - so very popular and so very disliked in certain circles. It is worth noting that a lot of sites with high traffic work without a problem in PHP. Even though it's more than 18x slower than C. It's already over a row of size slower.

    We will discuss the last two places as a couple. This couple is Python (almost 40x slower than C) and Ruby (slightly more than 44x slower than C). These are two languages that unabashedly wrung out several-minute test times. You have to admit - these are no longer dizzying speeds. Despite this, both languages work well in web dev, and Python has recently been making waves in other areas such as data science, machine learning and AI. In both, a nice, expressive and readable syntax is a strong incentive.

    [embed]https://www.youtube.com/watch?v=z3Mw4WJkDKM[/embed]

    Now we know which languages do and which do not.

    So what?

    Probably for a gray programmer who does not work with an unknown how loaded applications is basically just a curiosity. After all, he will not feel the need to change the programming language for performance reasons, especially since there are a lot of components that can be optimized along the way. Indeed, even with a poorly written, slow application with reasonable caching, you can go quite far. Worse if someone does not notice the need for optimization. This happened with our class at the height of its success-it was clearly evident that this app was not designed for big traffic. Of course, the speed of the language is very important in the case of high traffic or in the case of processing in close to real time. I don't think we're gonna find Ruby and Python here. Facebook decided that PHP performance was not enough and developed a virtual machine to fire up the language to cope with the growing number of users. Probably if they wrote in Java they would not make a virtual machine, but solve other problems related to this technology.

    It must be admitted that measuring performance in this way and attaching a lot of weight to a particular place, and the result to two decimal places makes little sense. In fact, the speed of C and C ++ can be comparable, as can Java, Swift, C# and go. It's also possible that node.js will not be in the real world as much as 2x slower than go. However, the fact that PHP is more than 2x faster than Python and Ruby will be felt in many applications, as well as the fact that it does not keep pace with the forefront.

    The list of implementations shows many approaches to writing the fastest one. In some languages-especially high-level ones-we find after several attempts, where the fastest from the slowest differs almost by a row in size. Hence, writing fast code can be difficult and requires a lot of energy, time and thought. It also shows that sometimes you just need to change the implementation, not the languageto get a decent working code.

    PS: there is another Cossack language, which is not in this list. Rust-he beat in two C benchmarks, but overall is 27% slower. Not bad for a language you don't have to do malloc i free.

    CONTACTS

    Address

    1A Sportyvna sq, Kyiv, Ukraine 01023

    1608 Queen St, Wilmington, NC, 28401

    Email

    info@servreality.com

    Skype

    info@servreality.com

    arrow-btn