Why does erlang need a virtual machine?

Message passing is at the heart of Erlang - "Message Passing Through Processes".

But the concept of a virtual machine when it comes to erlang remains vague.

Any help?

+3


source to share


1 answer


There are several reasons for using a virtual machine:

  • Actors

    Erlang tries to be smarter than the operating system he runs on. Building OS processes is slow and expensive. Erlang has its own light processes, a scheduler that manages them and means moving them between cores. scheduling is proactive which gives soft properties in real time (with a virtual machine it would be very difficult)

  • Memory management

    Allocating memory in the OS can be slow, so Erlang can pre-allocate and manage memory internally. This is due to immutability of data structures and garbage collection .

  • Instruction set

    When you have a predefined set of instructions, it is easier to optimize. You can also build other languages ​​on top of the VM, like Elixir or Lisp Flavored Erlang .



There are probably many, many other reasons, but those I quickly wrote out of my head. Erlang's main goal is to create fault-tolerant systems (scalability is just a by-product of fault tolerance, since

+11


source







All Articles