4 ms·
Start here --> https://elixir-lang.org/getting-started/introduction.html https://elixir-lang.org/getting-started/introduction.html You will start feeling the m
by whizzkid 8y ago
Start here --> https://elixir-lang.org/getting-started/introduction.html https://elixir-lang.org/getting-started/introduction.html
You will start feeling the magic around chapter 4 with pattern matching and the rest gets just better :)
Try not to migrate your "how to .." thoughts from other languages into Elixir. It has some uniqe ways to solve everyday problems.
Have your interactive elixir console ready to play with as well, good luck!
- peteforde 8y agoAwesome! Thanks so much.
- whizzkid 8y agoNo problem at all! I am also a ruby guy, so i can easily say that Elixir will not disappoint you.
- Klathmon 8y agoPattern matching will break you. I get frustrated at least once a week trying to use it in a language that doesn't have it. My brain just thinks in pattern matching!
- macintux 8y agoIt's unfortunate when I encounter a language that has a crippled implementation of pattern matching (looking at you, Scala). After using Erlang, it's hard to accept anything less.
- vram22 8y agoHow are F#'s and OCaml's implementation of it, in your opinion?
- macintux 8y agoI’ve not tried either, although in my limited exposure to SML it seemed fine. The other related feature whose lack I regularly lament in most languages is multiple function heads, which apparently is rarely used in the ML family tree, bafflingly.
- sgrove 8y agoI haven't heard the term "multiple function heads" - is it similar to Haskell's way of defining functions? e.g. fib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2)
- macintux 8y agoExactly. I don’t know what the typical industry term for it might be.
- mgradowski 8y agoPattern matching!
- macintux 8y agoNo, it relies on that, but the creation of multiple function clauses via different matched heads itself isn't simply pattern matching.
- mercer 8y agoMultiple Dispatch / Multimethods (I think?)
- macintux 8y agoInteresting, it appears that multiple dispatch is accurate. Thanks.
- yosh 8y ago
- YorkshireSeason 8y agoWhat's wrong with Scala's pattern matching?
- macintux 8y agoI shouldn't have said "crippled." It's just much more limited than when used in Erlang. From digging a bit it appears to be somewhat the JVM's fault[0] and quite a lot of it is simply that it's a different type of language from Erlang. In Erlang, nearly every line of code involves pattern matching, regardless of whether the developer takes advantage of it or not. Every assignment statement, every function return, every function parameter, is an exercise in pattern matching. It's at the core of the language, not an add-on. As I mentioned in another comment, a closely-related feature that really shows it to its full advantage is multiple function heads/clauses. [0]: https://www.scala-lang.org/old/node/11982 https://www.scala-lang.org/old/node/11982
- YorkshireSeason 8y agoOK, I also don't like Scala's inability to deconstruct in the parameter list. I come from an ML background where that is possible. But I found it less bothersome in practise than I had originally anticipated. Erlang has pattern matching on bits [1] which is convenient, that would be nice to have, especially when writing networking software. [1] P. Gustafsson, K. Sagonas, Efficient manipulation of binary data using pattern matching.
- macintux 8y agoGood point on the binary pattern matching. I’ve rarely used it, but it is quite powerful. I was pleased to discover Python’s tuple pattern matching in function heads, only to be disappointed that it was removed in Python 3.
- vikingcaffiene 8y agoYou are completely right. I work mostly in TypeScript and JavaScript for day to day and I miss pattern matching so much. Object de-structuring is nice and all but once you've seen the possibilities in a language where its a first class citizen... everything else just seems inadequate.
- Klathmon 8y agoIt's getting there for us in JS land, slowly but surely! There's still a lot of discussions that need to happen (read as "mostly bikeshedding" IMO), but once they settle on the actual syntax, i'd feel comfortable to start using it with compilers. https://github.com/tc39/proposal-pattern-matching https://github.com/tc39/proposal-pattern-matching