> While running in the browser is a requirement for Eve, it's always been clear that using javascript directly was not a long-term option. So many of our implementation problems come down to lack of control over data layout. For Eve we need to implement:
> New types (like intervals) - but there is a space overhead of 24 extra bytes per object
Polymorphic comparisons - but dispatching on typeof is slow
Cache-friendly indexes - but it's hard to store multiple js objects sequentially in memory
Radix tries - but converting strings to bytes is slow
> We also want to be able to distribute native code for mobile devices and use real threads on servers. Lastly, there is some benefit to using reference-counting for the indexes so that we can avoid copying nodes when we know we have sole access.
> We ruled out C++ and D on aesthetic grounds - we have a preference for small, simple languages that we can understand completely. Rust wins points for safety and abstraction but the toolchain is not nearly as mature and there are issues that currently prevent compiling with Emscripten. C gives us less support in the language but is much more future-proof at the moment.
We needed control over memory layout and some path to running in the browser. I considered writing the data-structures in C and the rest in Lua but it would require more manual memory management than Rust and there is no clear path to compiling mixed Lua/C projects into Javascript.
> While running in the browser is a requirement for Eve, it's always been clear that using javascript directly was not a long-term option. So many of our implementation problems come down to lack of control over data layout. For Eve we need to implement:
> New types (like intervals) - but there is a space overhead of 24 extra bytes per object Polymorphic comparisons - but dispatching on typeof is slow Cache-friendly indexes - but it's hard to store multiple js objects sequentially in memory Radix tries - but converting strings to bytes is slow
> We also want to be able to distribute native code for mobile devices and use real threads on servers. Lastly, there is some benefit to using reference-counting for the indexes so that we can avoid copying nodes when we know we have sole access.
> We ruled out C++ and D on aesthetic grounds - we have a preference for small, simple languages that we can understand completely. Rust wins points for safety and abstraction but the toolchain is not nearly as mature and there are issues that currently prevent compiling with Emscripten. C gives us less support in the language but is much more future-proof at the moment.
I also wrote about our experiences with Rust later at http://scattered-thoughts.net/blog/2015/06/04/three-months-o...