0

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?

  • 1
    Lower level programs = faster. The reason is that higher-level languages usually require a VM which translates opcodes to machine code, therefore there exists this extra step that requires additional processing. To put it bluntly, number of instructions using lower-level languages is, well, lower - ergo there's less work. All that I wrote is under assumption that a fictional human using mentioned languages (higher and lower) knows what she's doing. Sadly, the truth is that mostly that isn't true :/ – N.B. May 27 '13 at 15:15
  • 1
    Programs that are written better run better. :) And it depends upon how high versus low you mean. The most efficiently written program at low level might most of the time be more efficient than one written at a higher level. But high level language compilers are very good at optimization, so the payback of time spent programming versus real-time performance gained isn't generally worth it. What makes high level programs slower is the use of fat libraries and methods that enable rapid development with the assumption that processing power will compensate for the inefficiency. – lurker May 27 '13 at 15:15

2 Answers2

1

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.

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
1

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.

StevenTsooo
  • 498
  • 4
  • 13