4 ms·
I like function chaining more. E.g. Elixir's `Map.set(map, field, value)` function combined with the `|>` operator, which feeds the value from the previous oper
by emerongi 5y ago
I like function chaining more. E.g. Elixir's `Map.set(map, field, value)` function combined with the `|>` operator, which feeds the value from the previous operation in to the function as the first argument:
person_map
|> Map.set(:name, "Peter")
|> Map.set(:age, 37)
|> Map.set(:married, true)
It's so much fun to look at a chain of generic functions working on a generic data structure, while keeping the code clear. Makes me feel all warm inside. Immutability and functional programming, ain't it nice, huh?
- aaaaaaaaaaab 5y ago>It's so much fun to look at a chain of generic functions working on a generic data structure, while keeping the code clear. Makes me feel all warm inside. Yeah, that’s usually a bad sign. Programmers who think some language features are “fun” usually end up overapplying them and making life harder for everyone who just want to do their job and ship stuff. Programming languages should be simple, boring and self-evident. Keep “fun” in your hobby projects.
- emerongi 5y agoYou do you. Software development is a large enough field, our paths don't have to cross.
- lainproliant 5y agoIn his case, I'm glad they probably never will.
- macintux 5y agoElixir (really, Erlang) has tightly-constrained semantics around immutability and exception handling that make this feature a natural application of the core concepts.
- pasquinelli 5y agoi'm confused, are you responding to their example or to their vibe?
- lainproliant 5y agoI wouldn't touch software development with a ten foot pole if it wasn't fun. It's fine to enforce a code style in your own projects, but proselytizing them truth from on high is a bit presumptuous.