9 ms·
If you're out shopping for a new language to learn, I would recommend giving Elixir as much (or more :)) weight as you might give Go, Rust or Clojure. Here's a
by rubiquity 12y ago
If you're out shopping for a new language to learn, I would recommend giving Elixir as much (or more :)) weight as you might give Go, Rust or Clojure.
Here's a few things that I really like about Elixir:
- There's a ton of great resources already out for learning Elixir. José's article here is a good intro but Elixir's official website has a very in-depth getting started guide[0]. Dave Thomas, the author of Pragmatic Programmer and Programming Ruby (arguably the book that helped Ruby grow pre-Rails), has written a great book titled "Programming Elixir"[1]. Authors at Manning and O'Reilly are also working on Elixir books to the best of my knowledge.
- Elixir ships with a great build tool, task runner and dependency manager named Mix. There is also a package manager already built named Hex[2].
- Elixir compiles directly to Erlang byte code, so you get to not only take advantage of a very mature virtual machine, but you also get direct interoperability with Erlang libraries! This gives Elixir a robust ecosystem of tools and libraries to use right out of the gate so you can be productive.
- I try not to judge a language by its syntax anymore, but I realize that some do. If that's your thing, Elixir has a Ruby-inspired syntax as well as great support for metaprogramming via macros.
- Elixir development is going very fast and the language is stabilizing more and more by the day. If you need the "1.0 stamp of approval", that should only be weeks to a couple months away at most. The community feels very strong for a language this early in the game. The creator of the language, José Valim, is also very fair and considerate when discussing the language.
- The pipe operator lets you take all of your small functions and easily show the flow of how the operations are applied. This is one of the killer features of Elixir for sure and I'm not sure when I'll feel like I've overused it.
- Testing is at the very forefront of Elixir. All projects generated using Mix (the build tool described above) come with a ready to go test runner. You can also embed tests in the documentation of your code and they too will be tested for correctness.
Now, to be fair, here's a couple things to keep in mind when learning Elixir. These might seem like negatives or challenging at first, but they quickly become some of your favorite parts of Elixir:
- Elixir is a functional programming language, so that can be quite different as most of us on HN I feel come from OOP backgrounds. You have to stop thinking in classes, methods and state and start thinking about data structures, functions and immutability. Elixir is dynamic though, so picking it up isn't quite as challenging as learning a functional language and type system at the same time.
- Pattern matching and recursion are going to be at the core of writing expressive systems. Thinking about problems recursively is mind-bending at first but will start to feel natural. Pattern matching will both make you never look at an equals sign the same way again and help you write very easy to understand function bodies.
- OTP and its well thought out patterns are going to be pervasive to your Elixir programs. If you've ever ran into an Erlang zealot, they probably were ranting and raving about how well Erlang scales and handles failure. OTP and the Erlang VM are the secret sauce. How this all gets accomplished will feel very foreign at first (thinking in Supervision trees and message passing) but stick with it.
0 - http://pragprog.com/book/elixir/programming-elixir http://pragprog.com/book/elixir/programming-elixir
1 - http://elixir-lang.org/getting_started/1.html http://elixir-lang.org/getting_started/1.html
2 - http://hex.pm http://hex.pm
- fisher-lebo 12y agoI've considered Elixir as something worth picking up next, but my question is, why would I chose it over Clojure when Clojure gives me similar functionality (macros, some concurrency), but much deeper library options?
- rubiquity 12y agoThat's a tough question to answer as Clojure is a really great language and Rich Hickey is someone whose every word I'll read or listen to in a video. Someone more well-versed in Clojure than I can probably answer this better, but in my opinion: - Clojure runs on the JVM, so Clojure's concurrency is still sharing memory deep down, whereas Elixir is not. - I would think Elixir has deeper library options than Clojure due to having interoperability with Erlang. I guess in Clojure you get all the Java libraries too, though. - While Leiningen is a much better build tool than other JVM build tools, it still reeks of too much configuration. Mix is very, very simple. - Clojure, for sanity purposes, requires using a very Lisp-specific development environment. Clojure isn't the only language I use so using something like vim-fireplace or Emacs just for Clojure was a bit much for me. I'm happy to be wrong on any of my points above and again I think both Elixir and Clojure are great.
- klibertp 12y agoIn my experience Leiningen is so much slower for typical, casual use case than rebar and mix that it was a serious inconvenience. I didn't try to solve it by having something like a deamon always running in a background or something like this though, it's possible that this is already addressed. > requires using a very Lisp-specific development environment I'm an Emacs user, so it was very natural for me, but I think it can be a problem for others. On the other hand I hear that there are excellent plugins for widely-used IDEs for Clojure. Actually, as Clojure is a Lisp, the only thing you really need is an editor which handles sexps well. Emacs Paredit is really great for this: http://emacsrocks.com/e14.html http://emacsrocks.com/e14.html but as long as you get similar functionality you can use anything you want.
- yohanatan 12y ago