8 ms·
Popcorn: Run Elixir in WASM
- nelsonic 1y agoVery promising. But still not stable. One to watch.
- deleted 1y ago[deleted]
- Muromec 1y agoAtomVM is something like 1m when compiled, isn't it?
- mathek 1y agoCompiled to WASM it's ~700K, gzipped only 190K. But there's also BEAM code - the whole standard library is ~3M gzipped. We plan to do tree shaking to only include the used parts of the stdlib - then it should get way smaller for most use cases.
- Muromec 1y agoThat's a lot of wasm and beam. I tried to do it the other way -- compile beam straight to wasm and it seems to work in straightforward cases, producing wasm binaries in kilobytes sizes. With wasm fx it's even possible to do processes natively. You can find the link in bio. Cool thing would be to somehow wire it up to liveview to make it possible to run some parts on the frontend side transparently. I'm not doing any active development on it right now, but it looked pretty doable when I tried last time.
- mathek 1y agoI think it is Firefly's approach (https://github.com/GetFirefly/firefly https://github.com/GetFirefly/firefly). They put a lot of work into it, but never made it fully functional, and it's not maintained anymore. So I agree that you get smaller binaries this way, but I believe we can get to acceptable sizes too, without creating and maintaining a custom compiler.
- pesnk 1y agoCongratulations on the project! It works great, until we need to handle the best part of Elixir, that's creating multiple actors. This Task code, for example doesn't work. Enum.map(0..10, fn(_) -> Task.async(fn -> IO.puts("new process") end) end) |> Task.await_many()
- mathek 1y agoTasks seem not to work indeed, but spawning processes works. Try Enum.map(1..10, fn _i -> spawn(fn -> IO.puts("new process") end) end) Also, there are two scenarios: compiling code in the browser and running it, and running precompiled code in the browser. In the latter case more things work, for example the 'game of life' example uses GenServers, Supervisors and Registry: https://popcorn.swmansion.com/game_of_life/ https://popcorn.swmansion.com/game_of_life/ https://github.com/software-mansion/popcorn/tree/main/examples/game_of_life https://github.com/software-mansion/popcorn/tree/main/exampl... But yes, it's still unstable. Improving the stability is our main focus right now.
- Lord_Zero 1y agoI'm honestly surprised at how slow WASM is moving. As a very experienced web dev, when I first learned about WASM I was sure people would be building production UIs in Python and Golang and other traditionally server-side languages.
- Muromec 1y agoWasm doesn help much with UI, its more about moving parts of the server into the client as blacboxes with no access to dom. The blackbox can of course return the state of UI to be rendered/pathced, but that doesnt unlock much (if any) interesting capabilities for amount of overhead it adds
- eterm 1y agoWell there's blazor, which does that rather well, but it's treated with the same suspicion that most MS frameworks are. The fear that it'll be killed for poor adoption, leading to poor adoption. The blazor adoption probably isn't even that bad, but it's hard for MS to shake this stigma since so many people got burned on Silverlight and don't ever want to make the same mistake.
- throwawaymaths 1y agoI thought blazor failed because people didn't like websites that take minutes to load up all the websites assets. I'm not sure why, it could be: - Technical issue with blazor performance or blazor makes perf regressions hard to fix - blazor technical framework encourages programming style that is bad for perf - blazor or blazor ecosystem attracts programmers that can't deal with perf issues
- josephg 1y agoAs I understand it, blazor really needs WasmGC in order to have good performance and small bundle sizes. Otherwise, blazor is forced to ship a GC inside the wasm bundle - and that adds a lot of weight. And it also makes it more complex to share C# objects with javascript. WasmGC is supported in all browsers + nodejs now, but its still pretty new. Safari only started shipping it in December last year. I'm not sure if wasmgc is the default build for blazor, or what the status is on it. Blazor should be able to be good, small and fast. (Maybe even smaller than rust web frameworks.) But I don't know if we're there yet.
- codetrotter 1y agoFor anyone else wondering the GitHub repo is here: https://github.com/software-mansion/popcorn https://github.com/software-mansion/popcorn Couldn’t find any link to it on the article
- gitroom 1y ago[dead]
- Jump3r 1y agoHey, Kuba from team working on Popcorn here. I wasn't expecting it to be posted on hn but here we are. Feel free to ask me any question.