Hasty Briefsbeta

Bilingual

Popcorn: Run Elixir in WASM

a year ago
  • #WASM
  • #Elixir
  • #Web Development
  • Popcorn is a library that enables execution of Elixir code within web browsers using WASM.
  • Compiled Elixir code runs in the client-side AtomVM runtime, with APIs for JS-Elixir interaction.
  • Popcorn provides serialization, communication handling, and ensures browser responsiveness.
  • Setup involves adding Popcorn as a dependency, configuring JS and Elixir WASM entrypoints.
  • JS setup includes generating directories for WASM and including scripts in HTML.
  • Elixir requires a WASM entrypoint module with a `start/0` function and configuration.
  • Communication between JS and Elixir is managed via messages and direct JS execution from Elixir.
  • Popcorn's API includes methods for sending messages, executing JS, and handling events.
  • Limitations include missing NIFs from OTP, no support for big integers, and unstable API.
  • Under the hood, Popcorn uses AtomVM runtime compiled via Emscripten, loaded in an iframe.
  • Popcorn is created by Software Mansion, experts in web, mobile, and multimedia solutions.