
Why Elixir (2014) - brudgers
http://theerlangelist.com/article/why_elixir
======
anko
I really am in awe of Elixir. I think it's an amazing language, and it
introduced me to Erlang and OTP. I've come from using scala actors, and I can
do more in way less time, less memory, and similar performance if I use
Elixir.

That said, there are some things that suck so hard about it.

The log messages suck. If I want to use them in production and actually ship
them to ELK or similar, the format really sucks.

Getting information on what happens at compile time vs run time is hard.

How do you handle operating system signals? like when your autoscale group
decides to scala down and you get a SIGTERM with some time to handle it, what
do you do? wrapper scripts suck.

Not many great design resources.. I mean I've got lots of books on OTP. But if
i'm building a daemon which reads off a queue and talks to some databases -
where are some patterns I can follow? How do I handle config? What if I want
to hotload it?

What command do I run? when do I run an app vs compiling it? What If I want
command line args? Where's a good example of writing an app, which is a
daemon, and using an escript to reconfigure it at runtime?

The error messages. Holy hell. What actually caused a pattern match to not
work? what is it expecting? especially a few function calls deep - like
interaction between tuples and arrays and keyword lists.

Flow / Genstage and getting them into a supervision tree? what's the best
practices.

I want to introduce it to my workplace but without some of these common
patterns easy to find, it's kind of a risk to the business.

~~~
plainOldText
I know it's probably not the answer you're looking for, but you can learn a
lot by just reading the code of popular Elixir libraries, such as Ecto,
Phoenix, etc.

Error messages have gotten better in Elixir 1.5 The whole ecosystem is
actually getting better with each release.

For shipping to production I use 'distillery'. You create a 'release' and you
can even instruct it to read some arguments from the env vars.

But yeah, more resources would definitely be welcome. Hopefully as more people
start using the language, more resources will be created.

~~~
anko
I appreciate the response, at any rate.

I will read more libraries; hopefully I can find some which use flow.

I have used distillery but I find myself going down a pretty big rabbit hole
just to release something which in most languages is pretty simple. I will
look at it again.

~~~
andruby
If it's any help: I use docker multistage to build a barebones alpine docker
image. It uses distillery.

I based my dockerfile on
[https://gist.github.com/bsedat/16cb74ebc8ab0ed61ac598a129b0a...](https://gist.github.com/bsedat/16cb74ebc8ab0ed61ac598a129b0a7ea)

Blogpost: [https://zorbash.com/post/docker-multi-stage-elixir-
distiller...](https://zorbash.com/post/docker-multi-stage-elixir-distillery-
releases/) (I'm not the author)

~~~
thejosh
I just got the same setup this week. Docker multistage builds are amazing and
make builds super small and awesome. You can ship releases without having to
install Erlang or elixir on the imag, and just use what distillery has.
Distillery really is amazing.

------
MartinMond
Very relevant to this: How to sell Elixir - a talk from today's ElixirLondon
[https://speakerdeck.com/evadne/how-to-sell-
elixir](https://speakerdeck.com/evadne/how-to-sell-elixir)

~~~
pjmlp
Somehow I get the feeling Elixir is the new Ruby, every time I go through such
presentations.

Basically it looks like the escape route for Ruby developers that care about
performance.

~~~
jmcgough
Elixir really isn't just Ruby with better performance. The two look
syntactically similar (and have some similar tooling, from rubyists who've
moved over to elixir), but that's about where their similarities end.

Ruby really isn't designed for building complex concurrent systems. Erlang/OTP
is designed specifically for that.

When I need to build something that recovers from failures in Rails, it means
code that is littered with try/catch statements. I recently wrote a basic
caching system in Elixir for a project at work. There are plenty of ways for
it to fail, and I handle none of those situations. I let it crash, bring it
down gracefully, and then bring it back up in a healthy state. You can write
truly fault-tolerant programs on top of a very powerful and stable VM.

~~~
pjmlp
As someone working across JVM, .NET, C++, Android and iOS, I don't have any
use case for Elixir.

If I ever would need BEAM, Erlang would be quite ok, given that I was quite
comfortable with Prolog in the past and do like the syntax.

Hence why I kind of see it as BEAM for Ruby developers, even if I am way off
what is actually happening on the BEAM world.

~~~
Southy
100% This.

The use cases for OTP are actually quite narrow, despite what Erlang/Elixir
evangelists tell you.

Discord is a fantastic use for OTP. Writing a CRUD app with a couple of
reactive/interactive pages for comments on videos and few thousand users, OTP
is overkill.

If you have an app that needs the scale and safety of OTP, then which language
you pick makes no difference.

Phoenix is a really cool project, written by great developers and the
community is probably the nicest and most helpful you will ever meet. But how
many companies/projects need the performance and redundancy of Phoenix/OTP in
their web application at the cost of not being able to hire developers?

~~~
hesarenu
Elixir is very easy to learn. I suppose at the end of day you would be
spending more time designing your architecture rather then language.

~~~
Southy
I disagree that Elixir is easy to learn, the syntax ok, it's weird compared to
most OO languages, but actually using OTP is a real paradigm shift that
requires a totally different way of thinking about issues. I did not find that
easy at all.

The other issue is that Elixir and Phoenix have become joined at the hip in
the same was as Ruby and Rails, and Phoenix didn't click with me at all,
coming from the JVM world I really didn't get on with it.

After reading Programming Elixir, Elixir in Action and Programming Phoenix I
decided that it wasn't an easy way to make web applications that don't need
OTP, and in fact I couldn't imagine a scenario where any web application I
would ever write would need OTP (for the whole thing anyway, I can imagine
cases where small parts of a larger system could benefit massively from fail
fast architecture)

Edit: I would also argue that designing an OTP based system architecture is
harder than just writing a non distributed system and then adding in load
balancing or fail over.

~~~
anko
I don't think it's easy to learn either. The basics are easy, and the syntax
is easy, and writing some code that does what you want in the repl is easy.
But then you try to make a real application and you have more questions than
answers.

But, you can do OTP without making it distributed. Elixir is awesome in that
you have this actor based system (genserver) where the syntax gets out of the
way more than in any other language i'm familar with. So the business logic
running on these genservers is really easy to understand. And there is nothing
stopping you putting them behind message queues or load balancers. Most of the
time, that's probably appropriate.

------
salimmadjd
I started learning Erlang a few months ago and after spending a week with the
online class at Future Learn [0] I can understand why some people say Erlang
is more readable than Elixir.

I know if you're coming form Ruby world, Erlang almost feels second nature.
However, for people coming from other languages, I recommend looking into
Erlang as well. It's more expressive, IMHO.

[0] [https://www.futurelearn.com/courses](https://www.futurelearn.com/courses)

~~~
dudul
>I know if you're coming form Ruby world, Erlang almost feels second nature.

I'll assume you meant "Elixir", and seriously I hope people will give up on
this myth really soon. Yes, the syntax kind of look like Ruby, but the
platform is _nothing_ like it. I'm actually very scared for Elixir to see so
many Ruby developers moving to it, thinking that it's just "fast Ruby". They
may bring all their Ruby habits with them and defeat the point of using the
Erlang VM.

~~~
goatlover
If they just want "fast Ruby", then they should move to Crystal instead.
Elixir as a language is a lot different than Ruby, in addition to the platform
it runs on.

------
tmbsundar
> Elixir macros are nothing like C/C++ macros. Instead of working on strings,
> they are something like compile-time Elixir functions that are called in the
> middle of parsing, and work on the abstract syntax tree (AST), which is a
> code represented as Elixir data structure. Macro can work on AST, and spit
> out some alternative AST that represents the generated code.

The description above from the article seems like closer to the Lisp macros. I
have not programmed in Elixir yet.

Can someone who knows comment on the similarity here?

~~~
di4na
Technically Elixir is really close to a Lisp-2. It is not a real lisp as it is
not homoiconic. But it is not far and the macros are heavily inspired from
Clojure.

Elixir in general is probably close to Clojure than Ruby in its internals. And
well Erlang of course.

------
keithnoizu
I've been working primarily in Elixir for the past 3 or so years after being
in enticed by erlangs beam capabilities and spending time on there. Love the
language.

------
tmat
Because it makes me happy.. and OTP, Beam, Jose and team are amazing.

------
didibus
How's LFE in comparison? I don't hear as much about it, but I suspect (don't
know why), that its closer to Erlang, any comparison with Elixir?

