Home > Enterprise >  Why high level language is less memory efficient than low level language?
Why high level language is less memory efficient than low level language?

Time:04-20

The answers I searched said it is because it runs inside a specific runtime environment. Which environment are they talking about?

CodePudding user response:

The environment being talked about is dependent on the language, for example CLR for C# or JRE/JVM for Java. These are virtual machines which add more safety compared to low-level languages (Garbage collection for instance) but this in-turn introduces more overhead

A good starting point at least in the .net world to read about these 'environments' can be found at https://docs.microsoft.com/en-us/dotnet/standard/clr

CodePudding user response:

Let me try to explain it with this analogy. Assume you have a MacBook computer. You can install apps that will be running on your Mac natively from the App Store. Running apps from the App Store does not require any additional tools. So, now let's assume you want to run a windows program on Mac. To run window programs on your Mac you would need to install a virtual machine like Virtual Box for example. This VM will allow you to execute the window program on your Mac. But the VM will of course use additional resources from your machine like RAM and CPU. Hence overhead.

Many high level languages like Java, C# and Python use similar concept. They need a virtual machine to run on Operating Systems they are called interpreted languages. Languages like C, C and Swift are compiled languages. Compiled languages do not need a virtual machine to run. Hence compiled languages like C require less resources.

Checkout this video it examples white well: https://www.youtube.com/watch?v=I1f45REi3k4

  • Related