Command line utilities in Elixir

157 views
Skip to first unread message

Brad O'Hearne

unread,
May 20, 2016, 5:25:50 PM5/20/16
to elixir-lang-talk
Just curious....anyone using Elixir to write command-line utilities, as opposed to say Ruby or Python scripting? If so, are you happy with this approach? 

Thanks, 

Brad

Uniaika

unread,
May 21, 2016, 10:09:36 AM5/21/16
to elixir-l...@googlegroups.com
I wrote Majremind[1] some time ago.
The good thing is that the code is written in Elixir and it's my
favorite language.
The bad thing is (in my very humble and personal opinion) that it's not
a binary that I can "drop on any machine without having to think about
what's installed on them" (I'm looking at you, Go.)
It needs a virtual machine to be installed, and this very same VM needs
to boot up every time I use this script. That might make sense for heavy
operations, but not for trivial stuff (and God knows I'm an expert on
trivialities…
That's why I'm not very comfortable using Elixir as a CLI tool.

Otherwise, I'm perfectly happy with OptionParser and the pattern
matching features are quite helpful I think.


[1] https://bitbucket.org/Anwen/majremind
> --
> You received this message because you are subscribed to the Google
> Groups "elixir-lang-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to elixir-lang-ta...@googlegroups.com
> <mailto:elixir-lang-ta...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-talk/df5bac89-fa30-4616-bd2b-51ef789202ad%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-talk/df5bac89-fa30-4616-bd2b-51ef789202ad%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

René Föhring

unread,
May 21, 2016, 5:14:57 PM5/21/16
to elixir-lang-talk
Hi Brad,

next to several proprietary ones, I built two notable command line tools which are available on GitHub: One is Inch [0], written in Ruby and the other one is Credo [1] written in Elixir.

I can say that writing a CLI in Elixir is great and in no way inferior to the Ruby experience. As Uniaika wrote, pattern matching can come in handy in lots of situations and the effortless parallelization (is that a word?) of tasks (read a file, parse it and analyse it multiple times with different checks) is so dead simple that it makes parsing large CSVs, matching the against XML streams and writing the result to two different datasets almost a fun task.  Oh, and OptionParser is great as well.


Cheers,
René

Scott Ribe

unread,
May 21, 2016, 5:17:55 PM5/21/16
to elixir-l...@googlegroups.com
On May 21, 2016, at 8:09 AM, Uniaika <uni...@crypto-keupone.eu> wrote:
>
> The bad thing is (in my very humble and personal opinion) that it's not
> a binary that I can "drop on any machine without having to think about
> what's installed on them" (I'm looking at you, Go.)

While I don't like the requirement that the VM be installed, I also have written many command-line utilities in Ruby, and over the years have experienced a number of issues with version compatibility issues between Ruby & all the gems.

So I'm slowly coming around to the opinion that Elixir is probably *better* than Ruby, and if I was willing to use Ruby, then why not Elixir???

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





Uniaika

unread,
May 21, 2016, 6:06:49 PM5/21/16
to elixir-l...@googlegroups.com
I totally agree with you. Gemfiles are horrible for specifying a version
of ruby that's always different of mine ;_; (I have to edit them by hand
and I find this awful, but we're not on the ruby ML and I shall not
complain more about it).

Peter Hamilton

unread,
May 22, 2016, 2:06:40 AM5/22/16
to elixir-l...@googlegroups.com
Stream processing is a fantastic use case for command line utilities in Elixir. IO.stream(:stdio, :line) plus Stream/Enum functions makes it really easy to do some highly parallel/concurrent processing.

I haven't done a ton of general purpose stuff, but I've used it heavily in some specific data analysis tools.


--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/9aaac92b-2086-4540-179d-266cd6245ef1%40crypto-keupone.eu.

Brad O'Hearne

unread,
May 23, 2016, 5:32:17 PM5/23/16
to elixir-lang-talk
All -- thank you very much for your collective responses. They all were helpful and gave me good perspective for making some decisions on using Elixir for command-line tools. 

Thanks again. 

B
Reply all
Reply to author
Forward
0 new messages