Live data from Hacker News

Popcorn: Run Elixir in WASM

popcorn.swmansion.com

11–20 of 31 posts

Re: Popcorn: Run Elixir in WASM

#12
post #9

Earlier quoted context omitted.

Well 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.

I 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

As 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.

Re: Popcorn: Run Elixir in WASM

#13

I'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.

That’s actually what I feared the most and I’m glad we haven’t seen it happen.

Python and Go are not small languages, making users download entire runtimes to do something that can be done fine without them would be a huge shame. The performance problem with web UI is the DOM, not JavaScript.

Re: Popcorn: Run Elixir in WASM

#15
post #9

I'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.

Well 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.

Blazor wasm is just too heavy for most use cases.

In terms of speed, it's not even close to anything else in JS:

https://krausest.github.io/js-framework-benchmark/current.ht...

Re: Popcorn: Run Elixir in WASM

#16
post #13

I'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.

That’s actually what I feared the most and I’m glad we haven’t seen it happen. Python and Go are not small languages, making users download entire runtimes to do something that can be done fine without them would be a huge shame. The performance problem with web UI is the DOM, not JavaScript.

You can mitigate some of that with web workers, but it's a shame that multiple websites can't share a python runtime the same way they can on a shared linux box. You have to download a separate one for every website that uses it. But, if you follow that train of thought to the end, you wind up with the browser itself bundling those runtimes, just like it did with Flash back in the day.

I'm not sure any of this would be an improvement over what we have now.

Re: Popcorn: Run Elixir in WASM

#17
post #12

Earlier quoted context omitted.

I 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

As 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…

Doesn't Blazor include the entire .net core runtime? Or has that changed?

Re: Popcorn: Run Elixir in WASM

#18
post #13

Earlier quoted context omitted.

That’s actually what I feared the most and I’m glad we haven’t seen it happen. Python and Go are not small languages, making users download entire runtimes to do something that can be done fine without them would be a huge shame. The performance problem with web UI is the DOM, not JavaScript.

You can mitigate some of that with web workers, but it's a shame that multiple websites can't share a python runtime the same way they can on a shared linux box. You have to download a separate one for every website that uses it. But, if you follow that train of thought to the end, you wind up with the browser itself bundling those runtimes, just like it did with Flash back in the day. I'm not sure any of this would…

the only good reason to build these runtimes is to enable existing applications to be recompiled into wasm for use inside the browser - it doesnt make sense to greenfield an application that uses non-web UI libraries, only to then bundle the entire UI runtime with it.

Re: Popcorn: Run Elixir in WASM

#19
post #5

Congratulations 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()

Tasks 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://github.com/software-mansion/popcorn/tree/main/exampl...

But yes, it's still unstable. Improving the stability is our main focus right now.

Re: Popcorn: Run Elixir in WASM

#20
post #4

AtomVM is something like 1m when compiled, isn't it?

Compiled 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.
Post reply on HN