3 ms·
>>Any reasonably well engineered VM (e.g. V8, JVM, Go) will blow it out of the water. FYI, Go does not use a VM like V8 or the JVM; Go code compiles to native
by voidlogic 13y ago
>>Any reasonably well engineered VM (e.g. V8, JVM, Go) will blow it out of the water.
FYI, Go does not use a VM like V8 or the JVM; Go code compiles to native binary.
However, like many VM based languages and unlike (a lot of) C, Go should be write once, (compile) and run everywhere(Win,Lin,BSD,Mac). Also like many VM languages Go is type/memory safe and is garbage collected.
Edit: It appears V8 is also not a VM, it is a interpreter that performs just-in-time (JIT) compilation of source with no intermediate representation such as bytecode (Java instead JITs bytecode). This makes sense since Java programs are distributed as bytecode and Javascript programs are distributed as source. @calinet6: Thanks for pointing this out.
Life-cycles:
Developer's machine | Runtime
--------------------------------------------------------
Go: source->binary | exec binary
Java: source->bytecode | interp. bytecode / JIT & exec bin
JS: source | interp. source / JIT & exec bin
- pjmlp 13y agoIt is going to take ages to clear young developer minds that safe strong typed languages don't require a VM and we have to thank Sun and Microsoft to have spread that misconception.
- pstuart 13y agoAs an older developer, I'm ok with that :-)
- drivebyacct2 13y agoWhere does that come from? People who have only ever used Java or C#? I mean, there's nothing conceptually about VMs or strong typing that would lead to such a conclusion?
- pjmlp 13y agoI would say, it is developers that: - started coding after Java and .NET became mainstream - only know C and C++ as compiled languages, never tried anything else (e.g. Modula-2, Delphi, Haskell, ...) - lack CS background So they think any language with stronger type system than C or C++ can only be provided via a VM based runtime.
- prodigal_erik 13y agoDoes V8 specify a virtual machine and instruction set which you could make a real processor for? I thought it went straight from Javascript to either x86 or ARM.
- calinet6 13y agoCorrect, V8 compiles Javascript directly to machine code in a JIT fashion; there is no intermediate instruction set or bytecode. https://developers.google.com/v8/design?hl=es-ES#mach_code https://developers.google.com/v8/design?hl=es-ES#mach_code So in that sense, yeah, V8 is not really a VM but just a JIT compiler/interpreter.
- pjmlp 13y agoThere are native code compilers for Java, like gjc, JET, Aonix, RoboVM, Aicas, ...
- JulianMorrison 13y agoAlso, Go (via its usual compiler) is even more self contained than most binary languages: it compiles to a statically linked binary - it doesn't even depend on /usr/lib. If the CPU and OS is good, you can just throw around the binary with scp and run it wherever, no setup.
- pjmlp 13y agoThat used to be like that in any non UNIX OS back in the old days, direct calls to the kernel.