Interfacing scala/swing <-> iex -S mix

  1. I have a mix project. I can run iex -S mix in this project.

  2. I have a basic Scala/Swing app running with two text areas. One for input, one for output.

  3. I would like to connect Scala/Swing with iex -S mix

  4. The dumbest approach is to, from Scala, run the process iex -S mix, then interact with it via stdin/stdout. However, this is rather messy due to the need of parsing the output of iex -S mix

Question: Is there a way to run iex -S mix in some type of ‘server’ mode, where instead of interacting wit hit via stdin/stdout, we can talk to it via json blobs? (I.e. send commands to iex -S mix via json blobs and get the response back as a json blob). The goal here is to preserve as much of the structure of iex -S mix as possible, so we don’t have to re parse it.

Thanks!

The BEAM supports setting up a network where some nodes are Erlang/Elixir and some nodes are Java, that might be what you’re looking for. Take a look at JInterface in the Erlang documentation, or this writeup from “Erlang and OTP in Action”: Chapter 13. Communication between Erlang and Java via Jinterface · Erlang and OTP in Action

5 Likes