I don't know if is a question easy to answer, but I would like to understand the reason for languages like Clojure and Elixir needs a Virtual Machine to work.
Asked
Active
Viewed 31 times
0
-
1Unfortunately, this question is too broad to be on-topic here. That said, if you don't have a runtime (not necessarily a virtual machine; the Go runtime serves the same purpose), a bunch of extra work (garbage collection) that the runtime could otherwise handle for you needs to be taken care of by code the compiler generates. – Charles Duffy Apr 13 '20 at 15:18
-
Because then you can run code targeted to the VM, which can work across multiple physical platforms. If you write to the specific platform, you'll need to take into consideration differences in each platform. – Carcigenicate Apr 13 '20 at 15:18
-
...there actually *do* exist Clojure implementations that don't require a VM. For a historical (unmaintained) implementation, see https://github.com/takeoutweight/clojure-scheme – Charles Duffy Apr 13 '20 at 15:19
-
...one can also end up with better performance with a VM than without one, given a sufficiently high-performance JIT implementation recompiling the code after measuring how it behaves under real-world workloads. – Charles Duffy Apr 13 '20 at 15:20
-
But yes, if you look at some of your early VMs -- say, the [Z-Machine](https://en.wikipedia.org/wiki/Z-machine), which Infocom used for the games they sold in the late 70s through the 90s -- it was explicitly about portability. – Charles Duffy Apr 13 '20 at 15:23