wmnnd

wmnnd

The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries from Distillery Releases?

After all, Releases already bundle all Elixir/Erlang dependencies, so they seem like an ideal starting point.

I suppose, one could come up with an elaborate solution that would implement a custom boot process for the BEAM VM and somehow load all required BEAM files into it.
But why not create a “dumb” binary that is bundled with the release data (think self-extracting archive). It could dump its contents into a temporary folder and runs the app from there. A slightly more elaborate approach would be to use a user-space filesystem (FUSE on Linux) like AppImage does.

Combined with adequate compression, this could produce binaries of around 10 MB.

What do you think?

Showing Posts 1 to 10

NobbZ

NobbZ

As far as I know, it is already possible to create self-contained releases. They contain the runtime as well as erlang itself and therefore do not need anything installed if they are pure BEAM.

If they use NIFs they need the libraries installed.

If they open other programs, the other programs need to be installed.

Since the erlang runtime alone is already huge, I do not think this would make any sense to drive any further.

wmnnd

wmnnd OP

Of course can can create Releases that include ERTS, but you can’t put them in a single executable binary, can you?

I disagree. A compressed Elixir release including ERTS can be around 10 MB; looking at some CLI tools written in Go, they are definitely smaller (compressed at ~6 MB), but not by orders of magnitude

michalmuskala

michalmuskala

Yes, I believe this to be doable. With some changes to erts itself, it’s probably doable to just compile into a single binary and embed the modules inside of it - it already embeds the code for the “core” modules like erlang or init, etc. The primary reason why this is not happening is probably just because nobody did it yet.

OvermindDL1

OvermindDL1

I remember an erlang fork/tool thing way way back in the day that packaged everything up in a tar file that the erlang executable could ‘run’, no doubt you could pack those together too (this was why using the priv_dir call was important instead of hardcoding the path!).

sribe

sribe

There is currently no tool that will package an entire Erlang app & ERTS runtime into a single executable. Within the past 6 months there was a pretty extensive discussion on the Erlang mailing list about doing this: totally doable, probably not quite as easy as some might expect, just hasn’t been enough demand for it.

ODL: the only thing I know of packed up all the erlang BEAM files and a bit of code to run them, but not ERTS–are you thinking of something different that also packed ERTS into it?

wmnnd

wmnnd OP

Here is the most primitive version of a static “binary” I could come up with: A shell script that extracts its contents to tmpfs. I present to you:
A fully self-contained Elixir app with just 11.8 MB: => clock.sh

It’s compiled on a recent Ubuntu, so if you’re running any recent Linux distribution, it should work.

You can run it like this:

chmod +x clock.sh
./clock.sh

… and you’ll get the normal Distillery prompt. If you want to start the application, do ./clock.sh foreground
Here is the wrapper script: elixir-simple-dist.sh · GitHub

NobbZ

NobbZ

I accept this challenge and will try to run it in a naked chroot later the day.

OvermindDL1

OvermindDL1

It packed ERTS as well, and it was a definite hack but it ‘worked’. Mind that this was back in like 2001 or so…

shanesveller

shanesveller

Not exactly what OP is asking about, but for any passerby who want to glance at something they could already use today, Distillery supports self-extracting archives including a variant that cleans up after itself. I don’t believe the latter reaches for a tmpfs like @wmnnd has above, though.

https://hexdocs.pm/distillery/Mix.Tasks.Release.html#module-examples

Build an executable release

mix release --executable

Build an executable release which will cleanup after itself after it runs

mix release --executable --transient

NobbZ

NobbZ

Its a pity, but I have to postpone.

I just realised that I’m totally low on diskspace and I have to figure what can get deleted before doing anything else…

Where Next? Top

Trending in Discussions Top

juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
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
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
jam
This was an interesting post by Jose. Curious to hear what others think. Evolving programming languages in the AI era - Dashbit Blog Gen...
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

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews