
Flirting with Elixir - ptothek2
http://eng.localytics.com/flirting-with-elixir/
======
1_player
I've been "obsessed" with Elixir lately, and it truly is a breath of fresh air
in the current programming language landscape.

I've started with C, built a career with backend Python services/dashboards,
and spent some time on the "fringe" learning about Lisp, Scheme, Haskell,
Clojure. And once you rewire your brain with functional programming constructs
or immutability, it is really hard to go back to Python, using large libraries
feels too much like magic (if you ever used Django, raise your hands if you've
ever had to delve into the source code to understand what is going on).

I've had a fling with Go, I really like some of its ideas, namely static
linking, native compilation, no exceptions, easy deploy (I wrote a huge Django
1.6 app shipped as RPM for RHEL 5 enterprise servers, and that was truly the
definition of pain). I disliked the lack of functional constructs such as map,
reduce, filter, and it felt a step back from the "fringe" languages I've been
studying.

Then I discovered Elixir.

It's a mix between Haskell without purity and types and Clojure without
parens, with a Ruby-style syntax and a battle-tested framework for concurrency
and distributed computing.

It's like an immutable Python. With built-in virtualenv + pip tooling. And
first-class macros. And pattern matching.

Pair that with a sane standard library (unit testing? logging? documentation?
We've got you covered), a REPL, a LINQ-style lightweight ORM, and a very
interesting web framework built around modern tech (websockets, JSON APIs,
ES6).

And binary compatible with the most robust concurrency and supervision system,
Erlang/OTP.

I know I talk like a fanboy, but, man, programming feels like joy again.

~~~
vezzy-fnord
_Haskell without purity and types_

I'm getting quite tired of this "Every functional language I can't precisely
describe is like Haskell" sentiment. It's the "tastes like chicken" of
programming languages. Then again, the original article is remarkably devoid
of content, so I suppose it's only fitting.

Interestingly, avoidance of excessive magic is a large reason why I stick to
vanilla Erlang.

~~~
1_player
I agree that the comparison with Haskell is ill fitting.

The sentiment I wanted to express is that Elixir, like Haskell, is built
around function (or module) composition, is immutable, and state is
idiomatically handled separately (with separate processes and message passing,
instead of monads).

~~~
vezzy-fnord
Fallacy of composition. You're saying that any language with HOFs,
immutability and "idiomatic way to contain state" is ergo Haskell-like, which
is insane. None of these are even properties of Elixir, but of Erlang, which
Elixir inherits. Erlang is self-evidently not Haskell-like. At best such a
language would be merely functional. The actor model isn't even about anything
analogous to monads, it's a concurrency model that happens to simplify
concurrency control through isolation.

~~~
davidw
> insane

Rather than sling around heavy duty words like "insanity", you might try
putting yourself in their shoes: perhaps their only exposure to a functional
language is Haskell. Elixir is going to look a lot more like that, than, say,
C++.

~~~
vezzy-fnord
Irrelevant. Ignorance does not make inapt comparisons retroactively correct.

~~~
davidw
In technical terms, you are of course correct, and it's helpful to point that
out where people are wrong. But being wrong is not "insane" \- that's
incorrect in and of itself :-)

------
davidw
I've been using Erlang on and off since 2003, and used it heavily at the last
place I worked to build a pretty cool product, so I'm a fan. That said, this
article is a little bit hypey, although it's all correct as far as I can see.

* I'd still build most products in Rails, because there is _so_ much ecosystem that lets you get something up and running quickly. The exception being if I absolutely knew that the system had to aim for really big numbers from the get-go (which is not the kind of market I'm particularly even interested in these days), or had to be super-reliable, or some kind of semi-embedded system like what I did in the last place I worked. I loved Joe Armstrong's answer here: [http://erlang.org/pipermail/erlang-questions/2015-October/08...](http://erlang.org/pipermail/erlang-questions/2015-October/086379.html) \- "My goal would be to get something up and running as soon as possible and get users - and not worry about implementation details."

* By the same token, if you _know_ you need something with raw computing speed, Erlang isn't it either, as the article mentions. Although it'd certainly be possible for Erlang to farm out work to something faster, if the additional architectural complexity isn't a problem.

~~~
tobz
(SRE at Localytics here.)

I think one of the biggest things for us is that, primarily, we run Rails on
the frontend and Scala on the backend. Elixir is exciting because we could
potentially replace a lot of our frontend stuff with it, while not being
terribly far from Ruby syntax. It's "approachable". On the flipside, it's
potentially taking our Ruby code and making it more functional, getting closer
to our Scala side of things. It's a very nice middle ground.

In that regard, a lot of us here do feel very excited about Elixir, and so I
think that comes through as a lot of hype. We're looking at it through the
lens of what it could do for us, and we're naturally excited about that. :)

------
jrnkntl
I can highly recommend David Thomas' book Programming Elixir, I found it
complete to get a good grip and also a great introduction into functional
programming overall

[https://pragprog.com/book/elixir/programming-
elixir](https://pragprog.com/book/elixir/programming-elixir)

~~~
jeremy_k
Just got the confirmation that Programming Elixir and Metaprogramming Elixir
shipped. They can't get here fast enough.

------
capnhaddock
I love Elixir. I come from a Ruby background, and while I prefer Elixir now,
learning it has made all my code better.

LearnElixir.tv is another great place to learn it, if video screencasts are
your thing.

[https://www.learnelixir.tv/](https://www.learnelixir.tv/)

------
scragg
My good friend's company is hiring engineer(s) with Elixir knowledge if anyone
is interested.
[https://discordapp.com/company#join](https://discordapp.com/company#join)

------
resc1440
Are macros useful in a web development context? I don't feel like I've been
missing them in Django, but maybe I've just forgotten because it's been a long
time since I wrote anything substantial in Scheme. (Are Elixir macros similar
to Scheme macros?)

~~~
gamache
Macros are the most powerful tool for making DSLs, which means they pop up in
a lot of "specialized" niches, like web dev. You can make DSLs in other ways,
but without the ability to inspect and decompose code at the per-token level,
there are limitations to what can be done.

Elixir macros are like Scheme macros; they're fully hygienic (no variable
namespace issues), and they evaluate at compile time. The main difference is
that Scheme's main syntax construction is the linked list, and Elixir uses a
richer data structure, almost equivalent to JSON. Aside from the particular
structure the macro's manipulating, the concepts are the same.

Elixir macros are also used idiomatically to allow "smart" loading of modules,
e.g. specifying additional code to run in the caller's context rather than the
callee's. They fit nicely for this purpose.

~~~
eggy
Elixir is great, and I would loosely say it not homoiconic as Robert Virding,
one of the original Erlang team and creator of LFE (Lisp Flavored Erlang),
posits in an exchange with Jose Valim, creator of Elixir here[1]. In terms of
qualifying a JSON-equivalent data structure as richer, compared to lists in
Scheme or Lisp, I would disagree. I think you lose the code-as-data (down to
the languages fundamentals) win in Scheme. Devin Torres makes the statement
that Elixir is 'strongly homoiconic' [2], but his reference's definition does
not fit Elixir [3]. You cannot add new constructs or operators in Elixir. I
would say 'weakly homoiconic' if you are going to prefix an adverb on a page
that invents terms, which I still think is like 'a little bit pregnant' \- not
logically consistent. I do not code for a living, so I can choose things on an
interest basis, not a popularity or job market index. I am learning both
Elixir and LFE, and Erlang by default, but I am gravitating towards LFE. I
think LFE on the BEAM and Clojure on the JVM, makes for a good argument for me
to stay in the Lisp world, and not the Ruby, ROR, or Elixir one.

[1] [https://groups.google.com/forum/#!topic/lisp-flavoured-
erlan...](https://groups.google.com/forum/#!topic/lisp-flavoured-
erlang/ensAkzcEDQQ)

[2] [http://devintorr.es/blog/2013/06/11/elixir-its-not-about-
syn...](http://devintorr.es/blog/2013/06/11/elixir-its-not-about-syntax/)

[3]
[http://c2.com/cgi/wiki?HomoiconicLanguages](http://c2.com/cgi/wiki?HomoiconicLanguages)

~~~
gamache
Thanks for the reply! I read the "[1]" link you posted, and the word
"homoiconic" doesn't appear anywhere. Elixir code and data share the same
native data structures, ergo Elixir is homoiconic. Virding's point is that
Elixir lacks reader macros. For real-world usage, I consider that more of a
strength than a weakness. :)

