Why does erlang need a virtual machine?
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
source to share