belaustegui

belaustegui

Is Elixir adequate to build a cli tool?

I am thinking about building a tool to use from the command line.
The tool would provide a set of commands that interact with a remote API (from a bug tracking service, imagine something like Jira). The objective of the tool is to provide an alternative way to perform simple modifications directly from the terminal, instead of having to open the page in the web browser, etc.

Ideally I want the tool to be distributed as a single binary that can be put in the $PATH and executed.

I’ve seen that Go and Rust (apart from the always beloved C) are adequate for this requirements. But the thing is: I’m in love with Elixir and I would love to write this tool in it. Would Elixir allow me to generate a ready-to-run binary file?

First Post!

sotojuan

sotojuan

You’d still need the VM installed in the machine and to start up before the CLI tool can be run so it’s not an “independent” binary like Go, C, or Rust.

Most Liked

belaustegui

belaustegui

Thank you all for your replies! This is why I love this community :purple_heart:

As @bbense says, I could use Ruby, Perl or Python. In fact the tool I am going to build is a replacement for an existing one that is currently written in Ruby. I am choosing to replace it because if I want to use the tool everywhere on my system, I have to add the gem in the global Ruby installation. This should not be a problem if the tool did not require other gems which get also installed globally. I consider this a little dirty and it is what I would like to avoid.

The idea of @brainbag and @Onor.io resembles more closely what I have in mind. Building an escript would allow me to distribute my package as a single binary with its dependencies bundle (it would still require the Erlang VM, but so happens with JARs).

I am going to opt for Go or Rust (I like more the Rust approach because it is more close to functional programming) because I want to keep the dependencies absolutely minimum, the ideal would be to distribute a binary that could be run as is. I am a little bit sad about not using Elixir, but @bbsense has a point when he says that “Where Elixir really shines for this kind of stuff is when you have a 24 core server and enough work to keep those cores busy”.

So, Go or Rust it is. Thank you all!

lrosa007

lrosa007

I’ve been using a cli project as an excuse to learn Rust. I considered a lot of the same things at first. Since my project has zero network interfacing, Elixir seemed like overkill. I’ve used Go before and although it was kinda fun, I didn’t get hooked in any where near the same way Rust or Elixir got me. FWIW, there is a lot of fast software written in Go.

bbense

bbense

So you don’t use any Ruby, Perl or Python?

As far as I know, only the only choice for a completely stand alone binary these days is Go.
( I’ve no idea what Rust’s runtime, need to check that out).

Even boring old C is dependent on shared libraries.

Everything I’ve written in Elixir is a cli more or less. Where Elixir really shines for this kind of stuff is when you have a 24 core server and enough work to keep those cores busy. That’s not every cli app, but if you have that scale of problem, it’s so much easier to deal with in Elixir.

While the default erlang runtime is 200meg, there is a lot that can be trimmed; escripts only require the erlang runtime. While maybe not comparable to a minimal Ruby or Python installation, it’s certainly the same as any Java app. Elixir cli’s at least start much faster than most java apps I’ve used, they do have a minimal runup time that makes them less than ideal for some uses.

Last Post!

lessless

lessless

I’d say use Rust. You can distribute a binary and learn a lot of cool stuff :slight_smile:

Where Next?

Popular in Questions Top

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
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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

We're in Beta

About us Mission Statement