5 ms·
Slightly off-topic, but can someone familiar with both Elixir and Erlang explain what Elixir provides in comparison to Erlang. I'm looking into using Erlang fo
by mands 11y ago
Slightly off-topic, but can someone familiar with both Elixir and Erlang explain what Elixir provides in comparison to Erlang.
I'm looking into using Erlang for a new project that requires extensive scaling and concurrency and am coming from a functional background so may be more comfortable with the traditional Erlang syntax. However it seems that perhaps more development and activity is happening on the Elixir side of things and it may be more productive in terms of tooling, libraries (such as Phoenix and Ecto), and support.
Thanks!
- hansihe 11y agoI have worked a bit with elixir and erlang lately, but i'm not means an expert. I have to say, the biggest advantage elixir has against erlang for me is the macro system. It seems to manage to combine a ruby-like syntax with lisp-like macros, and it works incredibly well. Because of this it is very easy to create DSLs.
- kungfooguru 11y agoI'm a long time Erlang programmer and still prefer Erlang. But anyone who asks about web programming I point to Phoenix. So if you are doing a web app, or have a web component, I'd suggest Elixir and Phoenix for that part :) Erlang developer tooling does need work. But we are getting there, we have a new build tool http://www.rebar3.org/ http://www.rebar3.org/ that also combines forces with Elixir for the package management https://github.com/hexpm/rebar3_hex https://github.com/hexpm/rebar3_hex
- unoti 11y ago> can someone familiar with both Elixir and Erlang explain what Elixir provides in comparison to Erlang. The syntax is nicer, but that's just a bonus. The real game-changer to me about Elixir vs Erlang is its macro system. This gives you runtime code execution and runtime code generation, similar to what makes LISP to powerful. There's a large amount of boilerplate involved in creating an OTP server, as you know if you've done any Erlang. Elixir's macro capabilities completely eliminate all the boilerplate. The source to both Elixir and Phoenix are quite elegant and educational to browse, and demonstrate this runtime code generation aspect very well. It's straightforward in Elixir to introspect code, represent that code as data structures, manipulate those data structures, then generate or execute that code, as you can in LISP. Elixir also gives a number of excellent tools that streamline the support process over vanilla Erlang. For example, Elixir's runtime tooling automatically manages dependencies for you (similar to node's npm), and automatically maintains the application string that you need to provide for all OTP applications. It also has improved capabilities for testing, which are also made possible by the amazing macro generation capabilities. > I'm looking into using Erlang for a new project that requires extensive scaling and concurrency and am coming from a functional background so may be more comfortable with the traditional Erlang syntax Elixir's syntax is still just as functional. They support a regular if statement, unlike Erlang, but generally it's just as functional as Erlang. Elixir eliminates a number of needless chores from Erlang, such as having to end some lines of code with a comma, and others with a period, and then shuffling punctuation around whenever you add or remove lines of code. That's a task I used to do literally a hundred times a day in Erlang that I don't have to do at all any more.
- vezzy-fnord 11y agoYou can do reasonable metaprogramming in Erlang with the syntax_tools and stdlib interfaces. Most famously was bringing back parameterized modules via a parser transformation for tools like BossDB to support ActiveRecord-like ORM patterns. I've looked at OTP the Elixir way and I do not see any real boilerplate reduction. The application-project dichotomy and the opinionated integration with a tool like Mix is also policy over mechanism. rebar3 does fine dependency management given its constraints of having to unify packages coming from disparate sources. The syntax is not nicer. It is a jarring conceptual mismatch to put Smalltalk-ish Ruby syntax over a language that eschews excessive monkey patching and dynamism like Erlang.
- haddadell 11y ago> You can do reasonable metaprogramming in Erlang with the syntax_tools and stdlib interfaces. You can also do concurrency in Ruby. It is not the same as doing concurrency in Erlang though. The same way doing metaprogramming with syntax tools, parse transforms and what not is nowhere close to a macro system. > I've looked at OTP the Elixir way and I do not see any real boilerplate reduction. So please look again? Take a look at Elixir's agents or tasks and explain how it doesn't lead to more readable and cleaner code than the GenServer equivalent in Erlang for the cases they fit. You could maybe point other criticism but saying "no real boilerplate reduction" just shows you didn't really try or care to give it a try. > It is a jarring conceptual mismatch to put Smalltalk-ish Ruby syntax over a language that eschews excessive monkey patching and dynamism like Erlang. This sentence is specially ironic given that Erlang inherits from Prolog, which is quite different semantically from Erlang, instead of using the more tradicional ML families. Also Erlang is pretty much a very dynamic language. I am a Haskell developer, I hate Ruby syntax and I programmed Erlang for a year. I would still choose Elixir over Erlang any day mostly because of the tooling, typeclass like polymorphism and the new abstractions (Task and Agent).
- vezzy-fnord 11y agoThe same way doing metaprogramming with syntax tools, parse transforms and what not is nowhere close to a macro system. I'd wager that's because no one has written tooling to make it compelling to the common programmer. Same with release management for a long time, and hot code reloading. I'd understand if you said that basic substitution macros are nowhere close to actual AST macros, but Erlang has far more than that. Take a look at Elixir's agents or tasks and explain how it doesn't lead to more readable and cleaner code than the GenServer equivalent in Erlang for the cases they fit. Those are sugar. It's not like you can't define your own behaviors in Erlang. People do it all the time, there's so many good libraries that go beyond stock OTP. I should really switch an entire language because of default libraries? This sentence is specially ironic given that Erlang inherits from Prolog, which is quite different semantically from Erlang Only traces. The Prolog influence of Erlang is severely overrated by a lot of people these days. Also Erlang is pretty much a very dynamic language. It ain't no Smalltalk. The runtime is very dynamic, and the typing is loose, but the Erlang language itself not so much, which I think is a strength. I am a Haskell developer, I hate Ruby syntax and I programmed Erlang for a year. Good for you, chap.
- yellowapple 11y agoA lot of Elixir folks try to claim that the syntax doesn't matter. They're lying to themselves: of course the syntax matters. Not only is it much easier and more consistent for the human brain to parse (even more so than Ruby, in my opinion; unlike Ruby, everything that should take a block - like 'def' and 'defmodule' - do (pun intended) take a block), but it also goes above and beyond what Erlang offers with things like its pipe operator ('|>'), macro support, defaulting to binary strings (if you use double-quotes; single quotes are Erlang-style lists of characters, which - while they have their uses (aside from the obvious interoperability with Erlang code) - aren't really as efficient), and (in my observation) greater consistentcy between what you can do in the REPL ('iex') and what you can do in actual source files. They're both great languages, but I think Elixir is a bit more refined, learning from Erlang's advantages and disadvantages and improving on them. It's basically what you get if you watch "Erlang The Movie II: The Sequel" [0] and actually try to write a language for Ruby hipsters with excellent taste in noserings while humming along to Bananarama :) [0]: https://www.youtube.com/watch?v=rRbY3TMUcgQ https://www.youtube.com/watch?v=rRbY3TMUcgQ
- mands 11y agoThanks all for your responses, really helpful!
- eggy 11y agoDon't forget LFE (Lisp Flavored Erlang), if you prefer a Lisp syntax to a Ruby syntax that runs on the BEAM, as I do, although Elixir has great momentum right now.
- sasa555 11y agoI've been doing full-time Erlang for five years, and I personally prefer Elixir. Elixir is semantically close to Erlang the language, and allows you to take advantage of all the great benefits of Erlang/OTP. It's benefit is dev's productivity. Creating OTP applications and releases is simpler, and there are tools in the language (e.g. macros, polymorphism via protocols, tidier stdlib), and around it (e.g. Hex package manager, mix tool, doc tests) that make developers' life simpler. All of this is possible in plain Erlang, but it's more cumbersome, and sometimes requires home-brewed solutions. Notice that I'm not discussing syntax at all, because it (mostly) doesn't matter. I actually like the Prologness of Erlang. What I dislike is that some chores require more of my time and yak shaving, compared to Elixir.
- lobster_johnson 11y agoMy impression is that Erlang/Elixir is excellent at the kind of decentralized networked services that people usually use it for, but less ideal for many other things. What's your experience with Erlang as a "day to day" language for more mundane stuff? For example, a lot of my work tends to revolve around working with data. Processing large batches of data, parsing (often it comes in the shape of XML), transforming, filtering, ingesting it into databases, and so on. I can do this easily in Ruby, but performance issues has driven me to use Node.js or Go for new projects. With Go it's ridiculously easy to build efficient pipes that can parallelize each step to my liking, backpressure included. It's also trivial to build small command-line tools as well as specialized daemons. I have a world of libraries (and bindings to C libraries) at my disposal: AWS, image processing, transcoding, PostgreSQL, XML, JSON, it's all there. Go is also decent at Unicode and string manipulation. I'm not wild about Go's performance, and everything I have seen of Erlang indicates that its performance is closer to that of Ruby or Node.js. Any comments here? Whenever I need to fire up anything related to batch processing in Ruby or Node.js, things take forever. Erlang's advantage here might be that it's easier to spawn remote processes to parallelize the workload.
- jake_morrison 11y agoComing from an Erlang background, I found it very easy to get started with Elixir, it has the same underlying concepts and power as Erlang. Elixir takes it to the next level, though. The syntax eliminates annoyances in the Erlang system, e.g. having to fool around with punctuation and work with binary strings. The Elixir standard library gets rid of inconsistencies in the Erlang libraries and it is organized to allow easy chaining via the |> operator. Then it has features like protocols which give the encapsulation and polymorphism of OO without needing objects. And finally we have macros, which are the "right way" to do metaprogramming, allowing ease of use at a Rails level without the mess underneath. Another big thing is that the Elixir community focuses on ease of use and out of box experience the way the Rails community did. So it's easy to get started and all the pieces generally fit together well, e.g. the mix build tool works great, as does the hex package manager, and relx release builder. With Erlang it's more DIY. We have recently converted a big Erlang project to use mix as the build tool, and it just eliminated a bunch of cruft. The interop between Elixir and Erlang is easy. So you get the best of both worlds, the ease of use of Elixir with the power of Erlang, with the highly mature runtime and libraries. And with Phoenix we get a web framework with world class ease of use.