Shipping embedded erlang application in native applications on the OS?

Hi,

I’ve been looking at GRiSP, which provides a way to run Erlang on bare metal and also supports Linux.

My question is: are there today any state-of-the-art approaches to embed Erlang inside native applications?

The goal would be to ship an application together with Erlang as a native app on macOS, Windows, and possibly iOS and Android.

I can already achieve this with some custom plumbing, but my main concern is the size of an Erlang release. In practice, it is around 20 MB, which is quite large for this kind of use case. Ideally, I would like to bring it down to something in the 5–10 MB range.

Does anyone have experience with this, or recommendations on how to reduce the footprint significantly?

Thanks in advance.

My question is: are there today any state-of-the-art approaches to embed Erlang inside native applications?

I’ve only seen elixir-desktop. I’ve done some hacks for erlang instead of elixir. It does however as you say, make a larger binary.

I would like to bring it down to something in the 5–10 MB range.

There are ways that can reduce the binary size, each has a trade off though.

In no particular order:

  • Use platform libraries instead of shipping your own (Welcome to complexity hell)
  • Download missing platform libraries at runtime if needed (Must be connected to internet)
  • Executable packing (sometimes picked up as a virus/malware by naive virus scanners, see * here, upx good, wrappe not being picked up by malware scanners yet)](https://lib.rs/crates/wrappe)
  • Use AtomVM (not full erlang support)
  • Stripping debuginfo {debug_info, strip} from beam/executables/libraries (makes debugging harder)
  • Compress the beam files via {erl-opts, [compressed]}
  • Add deterministic build option (saves ~12kb on my builds)
  • Not including source {include_src, false},
  • rebar3 using ‘minimal’ release profile (Haven’t investigated why)
  • Make sure your build (via rebar3 overrides) actually does this for dependencies too. (Sometimes this breaks parse transform codes, apparently)

I’ve go it down to 12 (android app), but not the 5-10 mb range. The only way for sub 5mb initial download was to download the parts from the internet at a later point. A lot of mobile apps do this.

Hope thats at least a little bit helpful.