pmjoe

pmjoe

I need to develop a CLI application and I’m wondering how suitable Elixir is for this kind of application. The application must be distributed to clients and it should be as simple as possible to run, ideally a static build with a single binary. I know Elixir has some build systems and I’m wondering if some of these systems can produce a binary, in the end, packing everything inside like the Erlang VM, etc, etc…

Protecting the source code is also desirable.

First 10 of 15 Posts Switch mode

ityonemo

ityonemo

You should not use elixir for this.

10
Post #1
hauleth

hauleth

Use Go, Zig, or Rust for that. Elixir is a poor choice there.

ityonemo

ityonemo

maybe I should be more specific about the different points:

ideally a static build with a single binary.

Not generally possible. If you’re okay with a zipped artifact that decompresses into a directory, I would argue that deployment with Elixir as a client application in theory could be easier, than say python, but I have not heard of anyone who has done this.

packing everything inside like the Erlang VM…

Releases (zipped directory) do this. But you must know a considerable amount about your target environment for this to work successfully.

Protecting the source code is also desirable.

This is probably a show-stopper.

Other concerns, if you are expecting a responsive cli app (think like grep) where you might be integrating it as a part of a toolchain that runs very quickly (like generating tab-completion suggestions on a command line), this is not going to be feasible. But if you’re building something where it is going to do something necessarily long-running (like fetching files over the internet) it’s not the worst. I deployed an internal CLI tool once that concurrently-downloaded files from dropbox, S3, box, gcloud… but this was internal and not meant for customer distribution, so realistically it only had to work on one flavor of MacOS, and one flavor of linux.

Also, the erlang vm will default to hogging as many processes as there are CPUs on your system, so you may want to think about that too.

HDT186

HDT186

You can have a look at Bakeware, which compiles an Elixir, a Scenic or a Phoenix application into single executable binary.

hauleth

hauleth

Bakeware still doesn’t main problem with Elixir for CLI tooling - startup time. Most of the CLI tools is one-time quick tools that are launched often and that finish quickly. In such environment Erlang features aren’t that appealing and do not bring much to the table except familiarity.

jswny

jswny

Any language with a runtime that’s not super light like Go is not going to be good for CLI applications. If you are making a CLI app which is going to run for a bit and won’t need to be called quickly and opened many times or piped into etc, you could get away with it. It depends on the use case but in general Elixir is definitely not good for this use case.

hauleth

hauleth

Disagree. Python, Ruby, Perl, etc. are quite good solution for CLI tools. Sometimes even Java is ok solution.

tme_317

tme_317

I’ve written several CLI apps in elixir for interactive use (i.e. converting data, automating ansible, etc) using escripts. Due to familiarity I write Elixir code much faster than anything else and it works great if you can don’t mind the ~200ms “boot time” (depending on machine of course) to run the CLI app as the whole VM must be brought up even for a quick task.

For me that is a good tradeoff for interactive use as I can control the small internal team’s environment these tools are distributed to and make sure proper Erlang is installed. Your case of “packing … Erlang VM” and “distributed to clients” leads me to suggest what others have already said in Go, Rust, etc which would be much faster to boot and easier to distribute. I haven’t tried Bakeware maybe that solves the distribution problem at least.

derek-zhou

derek-zhou

From a pure runtime startup time perspective:
perl < python2 < python3 < ruby < java < elixir < nodejs
So elixir is not the worst. Hell, many CLI programs are written in nodejs; I cringe every time I run webpack.

carterbryden

carterbryden

I think really the main reasons why I usually wouldn’t go for elixir for a CLI app is that you probably won’t get or need it’s best benefits in a CLI too. Things like reliability and recovery features, distributed computing, maybe concurrency. But you’d still have to deal with a lot of the tradeoffs - lower portability, startup times, etc.

Elixir is designed to do a lot of things really well but it’s hard to beat languages that were designed specifically to be good for CLI tools without trading off the things that make it great for all other stuff.

Then again if your cli tool needs to be able to run a long lived command with a focus on reliability and concurrency, elixir would probably be great.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
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

We're in Beta

About us Mission Statement