kanishka

kanishka

I have been brainstorming ways to share code between elm and elixir, might use it at work. Think some simple calculations like calculating price based on float input and some constants. Some options:

  • Rust, wasm, rustler
  • Gleam
  • Elixir / Erlang compile to js (haven’t found an active project)
  • Implement small DSL that serializes to json and interpret in each language
  • Use python (an existing language used in our stack elsewhere), ffi to python from elixir; brython or other python to js compiler
  • Don’t use shared language, just use a data driven test set in both languages to guarantee equivalent functionality

Other ideas? Most viable?

I am guessing rust is most viable.

Showing Posts 1 to 10

D4no0

D4no0

I mean why you would use a native interface if elm is used for frontend anyway, once you go over the network there is no reason to use anything beside https.

kanishka

kanishka OP

I assume you are suggesting making a network call to the backend to invoke the logic. I wanted something that could respond quickly (as checkboxes are clicked and unclicked, in a long form), so I didn’t keep “call the elixir backend” as an option for this case.

D4no0

D4no0

You never mentioned where the infrastructure will be located, if you plan on making a local application where you embed elixir and elm on same machine, then using some of your options might be possible (even though they don’t make much sense, there will be no visible performance gain).

If you need an active communication channel between server and client, then just use websockets. There is the phoenix_channels library that abstracts a messaging interface and luckily there is a client in elm also (if that doesn’t work well you can always use the official JS client), however at this point I would just use liveview as it already does what you want to implement from scratch.

hst337

hst337

Why do you want to share code? Share data! Use livejson!

marcin

marcin

I am trying an approach to use Gleam compiled to JS for FE and re-use it in a Phoenix app on the backend.
see: Regretting/Questioning my current stack Flutter + Elixir as solo dev for mobile app - #21 by marcin

kanishka

kanishka OP

Let’s say Amazon us east data center for backend, and California for client browser. Want library function calls (or network calls) to complete within 500 ms. I guess a websocket could support that need. We already use phoenix channels through elm on some pages.

kanishka

kanishka OP

After websocket, gleam was my favorite choice, but I figured rust is more mature at this moment.

kanishka

kanishka OP

Liveview isn’t really viable for a single page amongst dozens when you have a lot already implemented in an elm SPA.

marcin

marcin

So you will be using Rust on WASM, right? Is there some FE framework you’d use to manipulate the DOM ?

mpope

mpope

Maybe ElixirScript would be useful, but I don’t know if it guarantees consistency between calculations done in JS in a browser and an Elixir backend. (It also hasn’t had a commit since 2019)

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews