LegitStack

LegitStack

Best way to get Elixir to work with python?

I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it.

I’m very interested in Elixir, but we use Python at my place of work. I want to make an architecture of microservices, and I’d like to use the actor model more since I see it as a generalizable pattern that can compute across clusters of machines (a trend I see continuing). For both of these reasons Elixir has my attention, but I don’t think it would be right to try to convert everyone over to it at my work.

So I really have 2 questions. Firstly, is it worth trying to get Elixir to communicate with Python? And secondly, if so, how is it best done? What is the best pattern for achieving two-way communication across languages?

For instance, my thought is to use Elixir to make the microservices infrastructure and use it to initiate processes and projects written in Python.

Would it be better to simply use rx or some other semi-concurrent actor-model-like libraries in Python to approximate the kinds of computational structures across nodes that Elixir is made for?

I’ve read through:

But I’m looking for two-way communication. Is this perhaps the best resource for that?

Any input is greatly appreciated, thanks!

Most Liked

rvirding

rvirding

Creator of Erlang

Pyrlang is very much alive and being worked on and improved GitHub - Pyrlang/Pyrlang: Erlang node implemented in Python 3.5+ (Asyncio-based) · GitHub .

filmor

filmor

The main differences between erlport and Pyrlang are (as far as I can tell):

  • Pyrlang is being actively developed while erlport is on “life-support”, the original developer hasn’t interacted with the project in more than 2 years
  • erlport (as the name says) implements the port interface, so you launch a Python process from Erlang and interact with it roughly like you would with an Erlang process, internally by talking with it over stdin/out
  • Pyrlang implements a full node in Python (you have to start the Python process separately and interact with it using Erlang’s distribution mechanism
  • erlport uses a pure-python ETF serialisation while Pyrlang uses a Rust implementation that is very likely to be a lot faster
  • erlport is not async, to interact with Python you will always call a function

We have been using erlport for quite a while now in production. It works in general but the installation is a bit more hassle than it should be as it requires the (manual) installation of the erlport Python part.

I like the fact that you can start up erlport as a simple sub-process, though it shouldn’t be too hard to either add this functionality to Pyrlang (the port protocol is really simple and very close to how nodes talk to each other) or to start a Pyrlang node on demand from Erlang and just supervise the process as such.

bottlenecked

bottlenecked

Calling python/other_language code from Elixir could be more hassle than its worth, as it could complicate development and deployment (environment setup, packaging etc.)

So if you’re already using a service oriented architecture, I’d think about simply exposing functionality of your python services through eg HTTP or RabbitMq and consuming that from all-Elixir apps.

That could give you a nice separation and the confidence to introduce an unfamiliar language to your workplace (in an non threatening way to other devs too) and get a feel for it on something small/contained before deciding about full-on investment.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement