
Elixir is for programmers - rohshall
http://blog.pluralsight.com/elixir-is-for-programmers
======
rdtsc
I really like Elixir.

Not only does it have a clean, pleasant syntax, macros, but it has all the
good parts from Erlang, namely:

* BEAM VM (isolated heaps, very well tuned scheduler, concurrent garbage collection)

* Pattern matching, once you've tried it, it is hard to go back.

* Ability to call Erlang code

BEAM VM is really a secret gem and many didn't get a chance to play with it
because they didn't like Erlang's syntax (personally, I do like Erlang's
syntax, but I think many don't). Well there is little excuse now.

If you like DSLs and macros (yes, yes, I know it makes many people scared)
this you can do neat stuff like these projects:

[https://github.com/elixir-lang/ecto](https://github.com/elixir-lang/ecto) \--
DSL to query databases

~~~
knewter
This is what I came here to say. All of the 'raw language' niceties that
Geoffrey mentioned in the article are true, but for me one of the greatest
things in Elixir is processes. Just, the way the Erlang system operates is so
well thought out, I'm more impressed every time I learn something new.

Shameless self-promotion here - I run
[http://www.elixirsips.com](http://www.elixirsips.com), which is a screencast
series that releases 2 new episodes per week covering some topic in Elixir. I
started it out as I started learning Elixir, and I've been going for quite a
while now (I'm on Episode 33 next, so 16 weeks so far). It's the most fun I've
had with a programming language since I first saw Ruby, and I think the BEAM
VM is the future (as is Rust/Go/clojure's core.async, other concurrency-
oriented programming models, etc).

So yeah, Elixir's amazing and everyone should play with it. I think just
looking at these items mentioned in the article aren't even giving it a fair
shake - learn about Erlang's concurrency and distribution models, or else you
aren't even scratching the surface :)

~~~
jasonlotito
I'm a subscriber to Elixir Sips, and just wanted to say that the videos are
well worth it to anyone looking to get into Elixir. I'm a happy subscriber,
and look forward to more videos.

knewter doesn't know me, and I don't know him.

~~~
desireco42
Thank you for this resource.

------
john2x
Ever since I started getting into Clojure, I've been getting interested in
these other functional programming languages. Lately I've been checking out
Elixir. I don't know what draws me to it (most likely the pretty website and
logo :P, and partly because I hate the Java ecosystem). I want to get into it
as well, but I just don't see myself using it for anything? I mean for the
types of problems I'm capable of solving, Clojure (and Python) seems to be
sufficient. To me, it seems Erlang (and thus Elixir) only offers its
advantages when building _really_ large distributed systems. Is there any
other use case for Erlang/Elixir?

I'm still going to be reading up on Erlang/Elixir for fun and to expand on how
I approach problems, but right now I only associate Erlang with large
distributed systems and I want to add other stuff to that association.

~~~
rdtsc
> Is there any other use case for Erlang/Elixir?

Yes, the use case is usually for highly concurrent system. There just happen
to be quite a few of those in recent years. Multiple things happening at the
same time colloquially speaking. Now it won't be good for fast concurrent
problems, like say multiplying matrices, or computing FFT, you'd use a GPU and
Fortran for that perhaps. But think of large game server with multiple worlds,
and players trading with each other. Think of a large distributed database
(like Riak). Think of the backend of large VOIP systems with multiple calls
happening at the same time. Or maybe a large chat system (Ejabberd).

Erlang as a general purpose programming language is also interesting. It
forces you to think about problems in a different way. Actually 2 ways: --
functional and using actors.

Also, its primary characteristic and design goal is fault tolerance. That was
#1 item on the TODO list when it was designed. It is one of the very few
languages and systems that has that as the primary goal. Many of the other
features -- concurrency, isolation, run-time code upgrade, immutability of
data structures, kind of fall out of that. So that is another general area
that you might consider where using it makes sense.

On types -- many criticize Erlang for not having a static type system. Not all
is lost. Erlang has a way to analyze its types using dialyzer. It is a success
typing system.
[http://erlang.org/doc/reference_manual/typespec.html](http://erlang.org/doc/reference_manual/typespec.html)
. The more you annotate the code the better it gets. Dialyzer will not catch
all the errors BUT when it complains, it is guaranteed to be an error.

To go hand in hand with that. It has very neat (3rd) party testing tools
available. One of the most interesting ones are for Property Tests. These
allow you to specify model constraint on your code and it will automatically
generate tests to try to find failing use cases that break the constraint.

Anyway, hopefully this gives a bit more of an idea.

To go hand in hand with that, on the testing side it has

~~~
elbear
Your message got cut off.

~~~
felixgallo
he forgot to trap exit.

------
jweir
Here is a write up about Elixir by Joe Armstrong (he had a little something to
do with Erlang)

[http://joearms.github.io/2013/05/31/a-week-with-
elixir.html](http://joearms.github.io/2013/05/31/a-week-with-elixir.html)

~~~
rasur
Parts of it are almost readable!

~~~
gcb0
yeah. nothing like light gray on light gray to make my day...

------
troutwine
It's interesting to see Elixir mentioned more and more. I don't _quite_ see
the use-case for it, but I'm so content with Erlang I'm almost surely not the
audience the language targets. Will be fun to see if Elixir builds its own
community or if Elixir folks slowly filter into the Erlang community as a
whole.

\- - -

EDIT

It occurs to me that the HN crowd might like Lisp Flavored Erlang:
[http://lfe.github.io/](http://lfe.github.io/) It's a lisp-2 written by Robert
Virding, co-creator of Erlang, and is backed by a great group of folks.

~~~
adamors
Erlang is awesome, but the syntax is just so out there that it's hard to get
used to it when you're usually hacking with Ruby/Python/PHP etc.

If I would be working with a functional language for 8 hours a day, perhaps
Erlang wouldn't seem so alien, but I'm not so it is.

Elixir for this reason is truly a godsend, and perhaps with time I can see
myself sipping more and more Erlang because of it.

~~~
seiji
_usually hacking with Ruby /Python/PHP etc_

Erlang is designed to create solid production systems. If someone is obsessed
with quick hacks and fad-of-the-week programming, they will feel uncomfortable
in a real development environment.

~~~
gcb0
i don't know from your high horse, but from down here, erlang satisfies my
needs for badly written hacks just fine.

more so that all implementations have a in memory DB so i don't even have to
bother with that as i would have with php... so yeah, installing yaws and
writting <h1>hello world</h1><erl>...</erl> is as PHPish as it gets for quick
web prototypes.

~~~
gcb0
the above said, the easy of use of yaws is what makes me reticent to even
start to play with elixir. i'd be very pissed it i like it but had to go back
to plain erl for web prototypes.

~~~
banachtarski
Try [https://github.com/s1n4/leptus](https://github.com/s1n4/leptus)

------
Erwin
If you liked the nice simple assert, you can get an imitation in Python tests
using py.test:
[http://pytest.org/latest/assert.html](http://pytest.org/latest/assert.html)

Source code:

    
    
        def test_function():
             assert f() == 4
    

Output:

    
    
            def test_function():
        >       assert f() == 4
        E       assert 3 == 4
        E        +  where 3 = f()
    

Here's how it works: [http://pytest.org/latest/assert.html#assert-
details](http://pytest.org/latest/assert.html#assert-details) \-- when
importing the test module, all simple asserts are rewritten (which has some
limitations if side effects are involved).

No more verbose self.assertTheItemIsInThisList(item, list) at least.

~~~
subleq
The problems with side effects have been fixed for a while:
[http://pybites.blogspot.com/2011/07/behind-scenes-of-
pytests...](http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-
assertion.html)

------
bitwalker
I recently started programming in Elixir. I chose to rewrite the customized
Hubot instance I'm running at my company from the ground up in it - it's been
a great way to learn the language, and especially OTP.

OTP is really what makes Elixir (and Erlang for that matter) so impressive.
Supervised, lightweight processes just seems so obvious as a solution to fault
tolerance and concurrency - coming from C#, where doing multi-threaded
programming is error-prone at best, Elixir/OTP is a dream. I do miss the type
system from C# or Scala, but type specifications help to mitigate the loss.

The one other feature that has been really pleasing to work with is pattern
matching. Scala is the only other language I've used with some form of it, and
after using Elixir/Erlang's pattern matching, Scala's seems deficient in
comparison. It's an insanely powerful construct, I wish more languages had it.

------
pselbert
A couple months ago I got into Project Euler and decided to tackle all of the
problems with Elixir. It was a great way to learn syntax and performance
nuances. Definitely a tool that I enjoy using and will be keeping up with.

------
thyrsus

        if(condition, do: a, else: b)
    

looks like a function, but that implies Elixir does lazy evaluation so that
only one of a or b gets evaluated. Or is something else going on?

~~~
devinus
_if_ is a macro.

------
adambard
Edit: The below is actually wrong

> For years I’ve wanted to be able to write my own control flow structures,
> such as an each...else that runs an else block if the each is empty
> (Handlebars templates have this).

Actually, python does have a (little-known) `for...else` structure that does
what you want.

[http://psung.blogspot.ca/2007/12/for-else-in-
python.html](http://psung.blogspot.ca/2007/12/for-else-in-python.html)

~~~
dragonwriter
python's for/else doesn't do what the grandparent post asked for -- that post
asked for the else clause to execute if the container that was being iterated
over is empty, and in python's for/else (as your link notes) the else clause
executes whenever the for clause terminates _normally_ (that is, other than by
a break statement). These are very different constructs.

~~~
adambard
So it does. I wonder what language I was thinking of then.

~~~
Lazare
This is a long shot, but could you be thinking of the Django template
language?

[https://docs.djangoproject.com/en/dev/ref/templates/builtins...](https://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-
empty)

    
    
        <ul>
        {% for athlete in athlete_list %}
            <li>{{ athlete.name }}</li>
        {% empty %}
            <li>Sorry, no athletes in this list.</li>
        {% endfor %}
        </ul>

------
thedudemabry
Pot, meet kettle. Or whatever the positive version of that is. [http://steve-
yegge.blogspot.com/2006/04/lisp-is-not-acceptab...](http://steve-
yegge.blogspot.com/2006/04/lisp-is-not-acceptable-lisp.html)

------
mml
Someone should probably point out that it's homoiconic too.

~~~
6cxs2hd6
I think it's interesting the extent to which lisp is slowly but steadily
insinuating itself into people's brains and into new languages.

There are the modern, obvious lisps like Racket and Clojure.

Then there are things like Honu, Pyret, Elixir, and more, which sidestep many
people's "parenoia" [sic]. They do the homoiconic, macro thing without any
supposedly frightening s-expressions.

Because, as I read this post, I'm thinking, well hell, _all_ of these features
[1] are syntactic sugar that already exist in e.g. Racket, and if they didn't,
could be added by anyone. Especially anything like "I always wanted this
control structure in Python/Ruby/whatever", well, you can just _do_ it. This
is really liberating.

Sure you can argue that people will do dumb things with this capability, or
that you "don't really need X", and so on. But being able to do it when you
need/want is really awesome.

[1] I'm referring to the points in the post, not everything that Elixir and/or
Erlang can do.

------
alanning
I'm very interested in Elixir but I'm having trouble understanding the benefit
of the 'upcase' example at the end of the article. Compared to a single
function with a conversion table, a function per character seems like a
tremendous amount of overhead.

Is the purpose of implementing upcase this way to make it more easily
parallelizeable in the map/reduce sense?

~~~
metabrew
It's pretty cool.. read the "Okay, but just how metaprogrammable are we
talking?" section in this article:
[http://devintorr.es/blog/2013/06/11/elixir-its-not-about-
syn...](http://devintorr.es/blog/2013/06/11/elixir-its-not-about-syntax/)

------
eonil
How Elixir offer type check - compile time parameter validity check on each
specialized types - or similar feature?

Is this type inferencing language?

~~~
zhemao
I suspect it's actually done at runtime. Erlang for instance is dynamically
typed, but also has pattern matching. I suspect Elixir is similar.

------
craigyk
Learning me some Elixir now and I like it. I wish anonymous functions didn't
have different call syntax though.

~~~
kaonashi
There's talk around removing it.

[https://groups.google.com/forum/#!topic/elixir-lang-
core/HzU...](https://groups.google.com/forum/#!topic/elixir-lang-
core/HzUEAVmbD00)

------
twic
FWIW, Groovy also has those smart asserts. They're nice. Not a big enough deal
that i'd start a feature list with them, but nice.

~~~
girvo
Groovy seems like such a... Forgotten language, sometimes. For what it's
worth, I've always really liked it. And I hate Java with the fire of one
thousand suns.

~~~
vorg
7 months ago, Groovy wasn't even in Tiobe's top 50. Two months ago (Oct 2013),
it had reached #18. This month, it's back down to #46. The person who pulled
off that trick didn't forget Groovy, and in fact utilized the feedback effect
to keep the afterglow going. Just type "Groovy Programming" into Google and
see some of the links...

5\. www.infoworld.com Groovy breaks into top 20 list of programming languages

8\. www.eweek.com Groovy Programming Language Sees Major Boost in Popularity

22\. cacm.acm.org Groovy Programming Language Sees Major Boost in Popularity

24\. jaxenter.com Groovy makes debut entry into programming language top
twenty

30\. glaforge.appspot.com Interview about Groovy's popularity boost --
Guillaume Laforge's Blog

But Groovy's "surge in popularity" was probably timed to coincide with a due
diligence investigation on Pivotal Inc, or someone there selling a consulting
contract.

"After a long discussion with one of the Tiobe index readers, it turned out
that the data that is produced by one of the Chinese sites that we track is
interpreted incorrectly by our algorithms. So this was a bug," Janssen said.
"After we had fixed this bug, Groovy lost much of its ratings."
[http://www.infoworld.com/t/application-
development/c-pulls-a...](http://www.infoworld.com/t/application-
development/c-pulls-away-java-among-top-programming-languages-230603)

------
coolsunglasses
Too bad the lists aren't counting lists and are dumb cons cells. :(

Has a cool Leiningen (clojure) inspired build/dependency tool.

~~~
adambard
There are many things in Elixir that seem to be inspired by Clojure and/or
lisp in general (which I think is great, by the way):

* AST-level macros with quote/unquote

* Reducers (efficient list processing)

* Protocols (which are like inside-out interfaces)

~~~
coolsunglasses
The Elixir macros aren't built on homoiconicity though.

Reducers aren't really intended for processing lists, they're best for
processing vectors and trees.

------
ternaryoperator
Wow, that center-aligned text is hard to read!

------
andyl
I tried to like Erlang, but the syntax turned me off.

Elixir was just what I needed. Makes the power of Erlang accessible. I like
Elixir's docs, tooling, and syntax, and look forward to seeing it progress.

