ashton314

ashton314

Has anyone done any choreographic programming with Elixir? The idea is that, instead of writing parts of a concurrent system separately and hoping that you’ve gotten the interactions between clients and server right, you instead write a choreography from some global viewpoint; a compiler of some sort then takes this choreography and constructs projections for each participant in the system.

A recent paper implemented an IRC client/server with choreographies: Real-World Choreographic Programming: Full-Duplex Asynchrony and Interoperability

Has anyone been working on something similar in Elixir?

Showing Posts 1 to 10

D4no0

D4no0

I’m not 100% sure we are not doing this already in Elixir.

Care to share an example of how this would look like in for example an imperative language like golang or similar?

ashton314

ashton314 OP

See page 5 for and example in a Java-like language: https://arxiv.org/pdf/2303.03983v3 (that’s a direct link to the Real-World Choreographic Programming paper)

D4no0

D4no0

Makes a little bit more sense now. Building such a thing in elixir with metaprogramming is trivial, the other question is whether we need such a feature.

The processes from elixir are concurrent entities that implement message passing out of the box. That example could be implemented more or less with the features already present in Elixir.

ashton314

ashton314 OP

My question is this: has anyone made a library or tool that implements projection from choreography to endpoint?

UPDATE: I’ve looked around a little on hex.pm already and I didn’t find anything. Looking to see if anyone else knows more than I do on this.

D4no0

D4no0

Highly doubt it, such concepts that involve a paradigm shift need to be extremely good for anyone to take them seriously. I can see how languages like Java could greatly benefit from it, however in Elixir I doubt this improves anything over existing way to write code.

ashton314

ashton314 OP

The chief motivation for choreographies is that they produce deadlock-free programs by construction, which is a pretty neat property. (See paper for details.) This is especially compelling for environments that need strong safety assurances.

Elixir—while providing higher-level concurrency primitives than, say, Java—doesn’t do deadlock-free construction natively.

fmn

fmn

yeah, i would say “we” do. it feels to me like actor model kind of stuff, sooner or later enters territory of orchestration or choreography.

i guess it comes with sufficient scale/complexity of the system.

ashton314

ashton314 OP

OK, so it sounds like you’re saying that you (@fmn and @D4no0) feel like choreographies are a common paradigm in Elixir code (I agree based on my experience) but that no one is doing mechanical endpoint projection. That’s good! That means I’ve got some work to do. :slight_smile:

fmn

fmn

you could try to poke around slim intersection of “Elixir” and “BPM” / “Business Process Management”, no promises though :slight_smile:

in Elixir software i was witnessed, it was quite often bit implicit choreography baked into application itself.

at the end, it might be a default way of going things, no? particular app/service/actor knows that “if i got this (pun intended) i do that” etc. and when you have bunch of apps/services/actors which just know what to do when something happens, well, you have choreography, i guess?

codeanpeace

codeanpeace

At a high level, it sounds like this choreography overlaps quite a bit with OTP and the primitives it and Elixir provides out of the box. A choreography as I understand it captures both the participants at play and the types of messages passed between them.

For the first aspect, choreographing the participants at play translates to orchestrating processes and can be explicitly defined via Supervisors, DynamicSupervisors, and Supervision Trees.

Then for the second aspect, the types of messages being passed e.g. the security protocol notation used in choreographic programming e.g. Alice.expr -> Bob.x could be translated to Alice.expr -> Alice.call(Bob, {:expr, result}) -> Bob.handle_call({:expr, result}, Alice) assuming Alice and Bob were GenServers.

As far as I know, there aren’t any guardrails in place that ensures all messages that are passed are handled/acted upon aside from test coverage. For asynchronous communication, a process “casting” with its message is totally happy shouting into the void aka it’s message “left unread” in the black hole of the receiving process’ mailbox so to speak. But when it comes to synchronous communication, a process “calling” with its message will get temporarily blocked if left unread and surface an error if the reply is used downstream so that generally gets caught pretty quickly. Regardless, preventing missing callbacks could be a potential area where choreographic programming would shine.


It seems like a fundamental value add from a dev experience perspective is how workflows can be expressed/encoded as a sequence diagram via choreographies and then translated into projections that represent the participants in those diagrams with the required send/receive functions defined. In my book, both ways of “framing” can be useful and being able to flip between the two depending on the situation would be pretty sweet.

For example, it would be cool if you could just write some choreography that uses endpoint projection to generate the proper Supervisor and GenServer implementations or biolerplate. On the flip side, it’d also be very cool to create an editable “virtual” file that stitches together the choreography for a specific workflow rather than rifling through multiple files/functions from a stacktrace.

Where Next? Top

Trending in Discussions Top

AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4663 61218 595
New
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...
515 12931 101
New
wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews