inkeliz / karmem

Karmem is a fast binary serialization format, faster than Google Flatbuffers and optimized for TinyGo and WASM.
BSD 3-Clause "New" or "Revised" License
654 stars 28 forks source link

Support for Javascript/Typescript #24

Open delaneyj opened 2 years ago

delaneyj commented 2 years ago

In browser context if you want this to gain adoption a typescript encoder/decoder would be a big deal.

inkeliz commented 2 years ago

Currently, it supports AssemblyScript (which is TypeScript). I think it's not that difficult to port to TypeScript. However, since scripting language doesn't allow you to read information directly from the memory (such as *(uint*)(something)) the performance will drop significantly.

The TypeScript port will basically only use DataView (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) and follow the same strategy applied on AssemblyScript (including create non-native arrays and encoding to UTF-16). The DataView seems quite fast on Safari (WebKit), but slow anywhere else.


Honestly, I'm focusing on WebAssembly. The remaining languages to be supported is Rust, C# (I'm working on that) and maybe Haskell. Then, I'll start to add new features and improve the current code (and documentation), but not adding new languages.