5 ms·
Portability. Say I wanted to make language X run on all platforms, but I didn't actually care about compiling it on all platforms. I can just write a relatively
by herohamp 5y ago
Portability.
Say I wanted to make language X run on all platforms, but I didn't actually care about compiling it on all platforms. I can just write a relatively simple VM for each platform. This is one of the reasons Java was and still kinda is so ubiquitous
- nethunters 5y agoWouldn't writing an interpreter for each platform be less work and achieve the same goal as writing a VM for each platform? Edit: ^Aside from being able to execute the bytecode on any platform
- kaba0 5y agoAs others mentioned, source code should be distributed that way, and I think creating a simple VM is easier than a simple language parser. But of course, an optimizing one can be really quite complex in both cases.
- klyrs 5y agoWhy would it be less work? The interpreter will need to implement whatever operations a VM can perform, so a priori it's at least as much work. Bonus, if you can bootstrap the source->bytecode process, then you only need to write (and compile) that once to get a full-fledged interpreter on every host with a VM