The Neko Virtual Machine
nekovm.org
nekovm.org
I mainly know Neko as one of many transpiling targets for Haxe programming language [2] (10+ targets including JS, PHP, C++), and have used it many years ago for all my backend stuff.
[1]: https://hashlink.haxe.org/ [2]: https://haxe.org/
- unlike Neko, the bytecode is strictly typed, allowing it to be much faster
- there are two different ways to use it:
- HL/JIT, compiling to bytecode and using the VM
- HL/C, compiling to raw C code to gain an extra bit of performance and allow it to run on devices that don't allow JIT (mobile / consoles)
- the successful indie games Northgard (by the Haxe / HashLink creator himself) and Dead Cells use HashLink as their runtime- there is a VSCode breakpoint debugger for it (https://marketplace.visualstudio.com/items?itemName=HaxeFoun...)
- in the future, support for hot-reloading bytecode is coming (https://github.com/HaxeFoundation/hashlink/issues/145)
Are there any benchmarks somewhere?
Edit: It's significantly faster then Neko and about as fast as HXCPP target.
[1] Though in JavaScript's case, there isn't really anything Haxe-specific about it, it just uses sourcemaps generated by the compiler like other languages compiling to JS.
Minor criticism: It would be helpful to see some code so you can tell what you're going to have to be generating to use the VM. Especially since it's not bytecode or abstract machine instructions so it's hard to know what to expect.
Otherwise, this is an incredibly cool project, which I'm definitely going to check out more in the future. Out of curiosity, how does its performance and memory usage compare versus the JVM or even LLVM (for the standalone compiler)? It's a super cool idea to have a lightweight standardized VM to program for, but I think generating bytecode or LLVM IR would be easier to design a programming language atop, at least because it'd be less likely to be a leaky abstraction like JS transpilers. So it'd be nice to know if any more technical benefits.
One technical question, (forgive me I don't know what I'm talking about) why have a bytecode at all, since no users of the languages based on Neko VM will touch Neko PL themselves (usually), why can't Neko PL act as a bytecode?
Btw, a JVM target (generating JVM bytecode directly) was recently merged into the Haxe compiler. Previously there was already a target that generates Java source code, but that had some issues like slowing down compile times with the native Java compilation step that needed to be done.
This is almost always cache miss.
If the collection is polymorphic it's even worse because you dereference to access the dispatch table which then redirects you to the real value.
Furthermore, each variable will need heap allocation and tracking, stressing the garbage collector and the underlying allocator (unless you preallocate big chunks like Java).
> [...] Neko is very slow. The main reason for this is that it's dynamically typed. So every "value" in the VM can be either an Int, a Float, a Bool, some Bytes, an Array, a Function or Object, etc. And because this value needs to be recognized at run-time, its type together with its data need to be stored in the memory. [...]
I found the following three resources helpful in getting a bit of an idea about what Neko really is beyond being a target VM of Haxe.
Neko C FFI - https://nekovm.org/doc/ffi/
A comparison of Neko and Lua - https://nekovm.org/doc/lua/
Language Interoperability - https://nekovm.org/doc/multilang/
See https://haxe.org/documentation/introduction/compiler-targets... for a full list of targets.
These days, I start new projects in NodeJS because teams don't know about Neko. Which is a shame because Neko and the Haxe language solve most critisism of NodeJS and JS in general.
For instance, the Haxe VSCode extension itself is a Node project written in Haxe.
[1]: http://www.thebacklog.net/2008/11/12/open-source-flash-workf...