14 ms·
Good read. Curious about Elixir. Why would one use this over ‘plain old’ Erlang / OTP apart from the Rubyesque syntax, which might appeal to RoR devs?
by hestefisk 8y ago
Good read. Curious about Elixir. Why would one use this over ‘plain old’ Erlang / OTP apart from the Rubyesque syntax, which might appeal to RoR devs?
- schneidmaster 8y agoIt's 100% the syntax. It appeals to ruby devs and also I think it's a lot easier to grok in general. But you can write Erlang code directly in an Elixir file, you can use Erlang libraries directly in Elixir, and Elixir compiles to the same BEAM instructions that Erlang does, so there's functionally no difference in terms of capabilities or what happens when they run.
- qaq 8y agowell better unicode support too
- SteveGregory 8y agoThis is not totally true. It’s not 100% syntax. Elixir has one additional and widely used feature: macros. In Elixir, as in Lisp, you can transform your code as a data structure into new code. This is importantly used in Ecto, the de-facto object data mapper in Elixir. It’s also used in Absinthe, a library from the posted link for making GraphQL APIs.
- schneidmaster 8y agoYeah, this is fair. I was mentally lumping certain language features under "syntax" but that's not really accurate.
- ramchip 8y agoProtocols are also an important feature. `IO.inspect`, `Enum`, etc. are very nice additions.
- elcritch 8y agoIn general the standard library organization is superb and well laid out. It’s the only language I don’t have to consistently lookup "how do I do X with string", or “Y with a list".
- out_of_protocol 8y ago* consistent standard library (huge win IMO) * efficient utf8 binary strings (which is actually conforms with utf8 standard), no mixup with charlists * mix etc standard tooling * macros * enum stuff * pipeline operator "|>", which by its mere existence enforces input/output param's consistency in user-written functions etc
- jaytaylor 8y agoMany folks seem to prefer Elixir to "Plain old Erlang" because for those who come from an imperative and / or object-oriented background, picking up Erlang means taking on a significantly steeper learning curve.
- TylerE 8y agoIt's not just syntax. There are semantics differences. A big one is that Elixir allows rebinding of a variable. Erland does not, which tends to lead to ugly names since in erlang you can't do common reassignment patterns like x = x * someConversionFactor.
- AlchemistCamp 8y ago> Why would one use this over ‘plain old’ Erlang / OTP apart from the Rubyesque syntax The two really big features are macros and protocols.
- nathan_long 8y agoFriendlier tooling and documentation are a couple of reasons. Elixir's whole reason for existence is to make the Erlang programming model easier to use. Try it and see if it does.
- pdimitar 8y ago* Unified tooling (`mix`). * Tests inside documentation. * Macros. * Protocols. * `mix xref` has a family of sub-commands that gives you good code analysis (callers, callees etc.) * First-class Unicode support. All strings are UTF-8 by default (you can fallback to ASCII if you need it; there are also good transcoding libraries in both Elixir and Erlang).