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

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
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
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New
nseaSeb
I’ve just put together a small POC exploring PDF inspection from Elixir/Phoenix: The idea is pretty simple: drag & drop a PDF in a...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews