ElixirScript in browser for native web development?

I came across this YouTube video demonstrating the release of “PyScript” — a WASM module which is linked into a HTML page that then provides a programmable Python REPL and programming environment for front-end for python programmers so they don’t have to worry about or use JavaScript at all.

On the surface, it looks pretty impressive.

Curious if it would be possible to do something like this for elixir. If so, it might change a lot of the things we do in LiveView, etc.

Here’s the link. Would be curious as to thoughts on this? Thank you.

PyScript Demo

1 Like

Because of the nature of how the erlang runtime currently works, it cannot be deployed as a single binary in the browser, there were plans on rewriting it from scratch with the lumen project, however it is not clear whether it is still developed.

3 Likes

It is still being developed, but got renamed to GitHub - GetFirefly/firefly: An alternative BEAM implementation, designed for WebAssembly

9 Likes

Wow, this looks promising. I’ll star and contribute via GitHub. Perhaps you can do a talk on this at ElixirConf this September? Curious if this would allow us to program in Elixir on both front and back-end, using Erlang/OTP distributed network features to replace LiveView entirely…

2 Likes

That’s what I’m working on here: GitHub - bartblast/hologram: Full stack isomorphic Elixir web framework

2 Likes

Hologram looks interesting, though I must confess I don’t get all of it. The choice to maintain state on client certain helps for disconnected scenarios. I write mostly CRUD style database apps and not sure if client side would make best sense for that. Don’t want user to lose data they entered on form in event of error, don’t want different clients changing same data, etc. Would be great to see you do a talk at one of the ElixirConf locations or youtube demo or something. I’ve starred it on Github and will follow-along!

That looks interesting. Can you add a LICENSE to this project?

Hey @mrjbj, the file and database access will be done on the server, only the code that makes sense for the client will be transpiled automatically to run on the client (mostly UI). The whole thing will be similar to LiveView in that you will have components and update the state similarly, but the difference is that you will have Elixir code transpiled to JavaScript running on the client when needed (so no hooks required). Yeah, I’ll definitely prepare some demo and getting started guide, once I finish this big code base overhaul I’m in the middle of at the moment.

I am curious about how this transpilation works. Is there a lib out there that does that? Is it custom code? (Out of curiosity: did you evaluate gleam, which compiles to Javascript?)

Nope, I didn’t evaluate Gleam. It’s custom code, the expanded Elixir AST is transformed into IR and then a call graph is built, this way I know what runs on the client.

1 Like

@arcanemachine Here’s the license: hologram/LICENSE at master · bartblast/hologram · GitHub

1 Like