"why erlang tuple module is controversial?" Code Answer


i can't tell you what the discussion was within the great cabal that controls everything, but i can tell you a few reasons why i never have considered using this feature:

  1. it doesn't fit. erlang is functional and this is a weird introduction of oop-style structs-that-have-arms-and-legs sort of thing. i don't like my code to clash with itself.
  2. it introduces syntactic complexity and semantic abiguity but grants me no new superpowers.

    • complexity:

      1. "is attribute x of foo equal to 10 or 20 right now?"
      2. "why do i write dict:is_key(value, thingy) here and then thingy:is_key(value) over there?
      3. "do i really want to encounter code like dict:is_key(key, foo:get_value(key2)) all the time?"
      4. i already have an army of processes designed to do just this and move the complexity of state out of the process code and into the world of asyncronous messages (in code i can deal with an isolated snapshot of time within a single call of a function)...
      5. if i really need this isn't that what the process dictionary was for?
    • ambiguity:

      1. "is this a 'thing' i'm calling a method of, or a module function i'm calling?"
      2. "wait, wasn't this supposed to be functional?"
      3. "is it ok to put that in a closure and send it off somewhere else? what if 'somewhere else' is another node? do i have to start caring about that suddenly?"
  3. this introduces opaque state (bad) instead of an adt (good, and something we already have).

  4. nobody uses this, so why waste effort supporting it, especially considering the corner cases it might bring up. that's support overhead and effort i would rather see go into features that we all do use.
  5. the "gain" here is only perceived as a benefit to people who can't bear to part with java-isms. there isn't much difference between foo:is_key(key) than dict:is_key(key, foo). other than the fact that i am certain on first reading, even in a complete absence of context, that the data object being operated upon in the second version is definitely a dict.

erlang's symbol assignment (aka "single assignment") is great, why destroy that?

By Phil27 on June 19 2022
Only authorized users can answer the Search term. Please sign in first, or register a free account.