Introduction
Popcorn is a library that enables you to run Elixir code directly in web browsers using WebAssembly (Wasm). Your Elixir code executes in the client-side AtomVM runtime compiled to Wasm, bringing Elixir’s powerful concurrency model and functional programming capabilities to the frontend.
What makes Popcorn different?
Section titled “What makes Popcorn different?”Compared to JavaScript:
- Write concurrent, fault-tolerant code using Elixir’s Actor model with lightweight processes
- Leverage pattern matching and functional programming paradigms for cleaner, more maintainable code
- Use Elixir’s robust error handling with “let it crash” philosophy
Compared to backend Elixir:
- Code runs entirely in the user’s browser - no server roundtrips needed
- Reduced server load and improved user experience with client-side processing
- Direct access to browser APIs and DOM manipulation through Popcorn’s JavaScript bridge
Popcorn provides seamless APIs for communication between your Elixir and JavaScript code, handling serialization and ensuring browser responsiveness while your Elixir processes work in the background.
How Popcorn uses Wasm
Section titled “How Popcorn uses Wasm”Popcorn takes a unique approach to Wasm in the Elixir ecosystem. Unlike Wasmex, which allows you to execute existing Wasm modules within Elixir on the server, Popcorn is run entirely in the browser.
While Orb lets you write Wasm instructions directly using Elixir syntax, Popcorn runs your existing Elixir code unchanged in the browser through the AtomVM runtime compiled to Wasm.
This means you can leverage your existing Elixir knowledge and patterns – GenServers, supervision trees, and OTP behaviors – directly in client-side applications without rewriting your logic.
Popcorn is created by Software Mansion software agency - experts in React Native, Elixir, and multimedia solutions. Reach out to us!