

Binary pattern matching in Elixir - vvanders
http://zohaib.me/binary-pattern-matching-in-elixir

======
vezzy-fnord
I've been a noticing a trend recently whereby all the standard Erlang advocacy
articles, tutorials and feature overviews are taken, have 's/Erlang/Elixir'
run on top of them and reposted as if they're all novelties of Elixir.

~~~
59nadir
I don't know where you got this impression from. It's pretty much never
explicitly stated that anything is Elixir-specific. It just so happens that
Elixir is the top horse of today for representing the Erlang ecosystem and so
that's the vehicle people choose to present the features of that ecosystem,
mostly.

~~~
jacquesm
> It just so happens that Elixir is the top horse of today for representing
> the Erlang ecosystem and so that's the vehicle people choose to present the
> features of that ecosystem, mostly.

On HN maybe, but out there it is erlang ahead by more than just a noselength.
Elixir is nice and promising but by no objective measure is it 'the top
horse'.

------
jimbokun
Elixir code examples seem to come out very concise and elegant. It's similar
to Clojure in that way, with the emphasis on dynamic typing, immutability, and
functional programming. A major difference is the emphasis on pattern matching
(I know Clojure has this in libraries, but it's much more idiomatic in
Elixir).

Makes Elixir a nice stepping stone to functional programming from dynamic
languages like Ruby and Python.

~~~
djur
"Stepping stone" suggests only part of a journey -- is Elixir incomplete or
deficient as a functional programming language? What might the next step be?

~~~
jimbokun
OK, how about "entry point"?

It's an easier leap than jumping from Ruby into a strict, strongly typed
functional language like Haskell, Ocaml, or Scala.

~~~
djur
That makes sense. But Elixir is pretty fantastic itself, so I imagine a lot of
people would stick with it rather than moving on.

------
pepve
How would you do error handling for the binary data? Let's say you expect
something to match but it doesn't, what are your options then?

~~~
oomkiller
Well, if it is truly unexpected that it doesn't match the data, then you
should just blow the process up and have it be automatically restarted by a
supervisor. If the pattern is an alternative format, or something that you'll
actually want to match, you just define another function with that pattern to
test it against.

------
octatoan
This looks very interesting.

