This repository was archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Wasm backend: discussion on Datetime support #759
Copy link
Copy link
Open
Labels
Backend: WASMWebAssembly BackendWebAssembly Backend
Description
The current WIP wasm backend does not support Datetime. This thread is for discussing how we could provide Datetime for the new backend.
Implementing a datetime library from scratch in Wasm, Ergo or Assemblyscript is hard. If we want a reliable Datetime until end of summer, we'll have to find a short cut. The following option come to mind:
1. Let the javascript engine provide a Datetime library.
Pro:
- We could use moment.js as we do on the javascript backend.
Con:
- Not portable to non-js platforms (especially the Wasm spec interpreter).
2. Find a datetime implementation in Assemblyscript, or translate a Typescript implementation to Assemblyscript.
Pro:
- Does not add dependencies.
- Does not increase complexity of the engine.
- Everything but the datetime implementation is in place.
Con:
- I could not find a datetime implementation for Assemblyscript. We probably would have to adapt a Typescript one ourselves.
3. Use another compile-to-Wasm language that has Datetime support (maybe in form of a library), generate a suitable wasm module and call it from the Assemblyscript runtime or the Wasm contract module.
Pro:
- Portable from the runtime perspective.
- We could choose a mature Datetime implementation.
Con:
- Engine has to dynamically link 3 modules instead of 2.
- We add another language to the build process.
- Calling into the datetime lib is probably not trivial (we cannot easily return structs/tuples/strings.)
- Different language has different memory layout and management. More cognitive load / complexity.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Backend: WASMWebAssembly BackendWebAssembly Backend