Over the last few decades, many programming languages have been invented and put in use nowadays in many domains. This article will compare some commonly used languages in the codeforces website. The same algorithm is used for the tested languages and the problem has already been discussed in this thread: https://helloacm.com/a-funky-numbers.
Below is a comparison of some languages that can be found in this thread: https://helloacm.com/stdin-and-stdout-in-php
Using online judge gives roughly fair comparisons because the same hardware specification is used. Here are the quick comparisons over time and memory.
It is worth to note that using range function in Python maybe a bit faster than simple loop, however, at the cost of using more memory. Because the range function will perpare the set. Using xrange will be a bit faster if we intend to use one element per iteration.
Delphi 7 uses far more memory, to my surprise. Maybe it is because of the compiler switches (non-optimal settings).
The Java uses the most memory. If you aim the computational efficiency, the C/C++, Pascal may be a better solution.
C# offers a fast RAD (Rapid Application Development) approach similar to Delphi. However, since there are code security issues with the C#, it is often used in Server-side applications.
Delphi may sound a good trade-off if you want efficient solutions quickly. It is known as an excellent RAD solution under Win32 and it produces native code which are usually far more computational efficient than scripting languages, i.e. python, the byte-code-like languages, such as Java or C# (.NET)
We can still see that from this comparison, FPC offers the best solutions, as it uses less memory and executes the fastest among all languages.
It is suprised to see that the optimised PHP (with the help of e.g. Zend Optimiser) is very efficient, and may be faster than the C# code.
C/C++ are generally considered as the most sophiscated tools for developing system-level software, such as operating system, the hardware driver etc.
However, this comparison may not be accurate in all aspects, because the languages may be optimised in some particular aspects. For example, the pascal compiler will produce highly-optimised code for integer operations (bit operations etc) but may lack optimisation in the floating point computation, in this case, C/C++ may produce more optimised instructions.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Number-guessing game in Windows Batch Programming
Next Post: Fibonacci Number via Inline Assembly in Delphi