Do low-level programs run faster inherently, or--since everything is machine code in the end--am I misunderstanding?

StackOverflow https://stackoverflow.com/questions/16775983

Question

If I need to rephrase:

Are programs written in low-level languages essentially better performance-wise, or is there really no difference in the end?

Was it helpful?

Solution

Adding to what Martin is saying, when a high level language goes through a compiler, it is essentially decomposed into simpler instructions that the machine can understand. Compilers can be really good or really bad depending on what compiler you have. Some compilers allow great optimization while some are barebones. In the end they all go down to machine level code. The translation from code to machine level code is where the translation of speed really happens which is done by the compiler.

Imagine having two translators from English to Spanish. Imagine you tell them to translate a phrase. That phrase might get lost in translation. One translator might end up being a better translator in the end. Same with compilers.

Though there is some slight changes in the translations, you still get your message across. This is the same in the programming world. When you have a high level application, it does not make sense to write everything in machine code since that would be extremely inefficient. Also compilers are getting really good against assembly level comparison.

Again it all depends on the end application and what makes sense.

OTHER TIPS

The simple answer - it depends!

If you mean low level languages then languages that compile directly to code (C/C++/Fortran) could run faster than those which require a virtual machine (Java/C#/Python).

In practice VM based higher level languages haven't traditionally been used where highest performance is the requirement - so there has been a lot more effort in high performance Fortran than high performance C#. This also means that people with a HPC requirement won't generally pick Java/C# and so it isn't available on those systems, and so on....

That might change as the VMs get smarter. PyPy is a classic example, it's python written in python which should be uselessly slow - python isn't a fast language and writing it in itself rather than C should be terrible but it is often faster because it can analyse and pre-compile some parts of the program which would have to be parsed at runtime. Similarly you could imagine a C# VM which recognized certain comment tasks and automatically converted them into parrallel GPU operations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top