Skip to content

Instantly share code, notes, and snippets.

@pmarreck
Last active August 29, 2015 14:20
Show Gist options
  • Save pmarreck/fdbbcd2560893758fbf4 to your computer and use it in GitHub Desktop.
Save pmarreck/fdbbcd2560893758fbf4 to your computer and use it in GitHub Desktop.
The Things I See Missing From The Elixir Language

I think that folks are finally showing up to the Elixir party and (for the most part) liking what they see :)

I have only a small handful of criticisms after playing with Elixir for a while (which so far all seem like "Haskell is better in these areas," although I seem to still like Elixir better overall!)

  1. you can't define/override (per lexical scope) arbitrary infix operators, you are restricted to a small set. (In Haskell, for example, you can call any prefix function as an infix function.)

  2. you don't have any automatic currying. That's more Erlang's fault. Haskell has this, of course. In Elixir's defense, it's probably possible to define a curryable function definer using macros, like "defcurryable". Because, you know, what the hell CAN'T you do with macros? :) And Elixir has them.

  3. there is no clear distinction made between code with side effects and code without side effects. This is yet another thing I think Haskell gets right, because you can prove determinism when you can prove no side effects. Of course, Erlang/Elixir people correctly point out that every "receive" and "send" of messages to PID's, which pervades concurrent languages like Elixir/Erlang, is a side effect... but Haskell actually has deterministic concurrency libraries to combat this. Which is insane, but I digress. Elixir/Erlang's strategy is "it's gonna fail somehow, just accept it, log it and try again immediately." Which is a highly resilient strategy, to be sure.

  4. some odd things seem to be missing from the standard library and standard set of math operators, which is also Erlang's fault (as it does not include those either). For example, there is no ** (power) operator. And :math.ipow will actually have rounding errors with large integers, as it's from a floating point library, and floating point computations are approximate. I actually had to write my own integer power library and look up the fastest algorithm to compute it! https://github.com/pmarreck/elixir-snippets/blob/master/math_integer_power.exs What makes this somehow even MORE frustrating is that you can't even define a ** infix operator which calls this functionality, which has existed in pretty much every other language I've worked with.

  5. more difficult than in Ruby to learn by doing "discovery by introspection". In Ruby you can find all available methods on any object via object.methods; in Elixir, for example, it's hard to find certain functionality... is "length" in Enum or List? Or if it is in both, is there a difference between the implementation of those? This is a bit newbie-unfriendly, and someone should step up here to provide some kind of functionality lookup in iex. (That said, the built-in "h" function in iex to get docs on any Module.function is VERY helpful.)

  6. The hat (^) operator to force matching instead of reassignment. (Which isn't really reassignment, as everything's immutable, but I digress.) I get it now, I understand why it's necessary, I can use it just fine... but something about it still irks me. Tastes are funny like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment