4 ms·
I'm not an Elixir beginner but all those ampersands means that either one writes that kind of code everyday or one won't understand what it does when coming bac
by pmontra 4y ago
I'm not an Elixir beginner but all those ampersands means that either one writes that kind of code everyday or one won't understand what it does when coming back next month. Use names, not shortcuts.
- arrowsmith 4y agoThe ampersand syntax is extremely common in Elixir code - absolutely the kind of thing you'd write every day. If your Elixir developers find the ampersand stuff hard to read, you've hired the wrong Elixir developers.
- shakow 4y agoAmpersands are the builtin symbol for point-free evaluation in Elixir. If you forget what it means in a month, you will probably have other problems than this single snippet.
- pmontra 4y agoYou never know in advance who will work on code in a large project, how expert in that language and under which time pressure. I prefer to stick to a common ground between major languages that lets (say) someone that knows only JavaScript at least read the code and understand what it does. If it means that I have to write a few more lines or type more characters in variable and function names, I do it. I never appreciate where languages and developers want to do smart things. Boring and plain is much safer.
- shakow 4y agoIf you find yourself in such conditions that JS developers unable to google ‶elixir ampersand″ are the ones reviewing your code often enough for it to be a constraint while developing, your company has much deeper problems far up the command chain.
- pmontra 4y agoMy customers are small companies. Elixir is their choice.
- JediLuke 4y ago
- gregors 4y agoI very much didn't like the ampersands the first couple of years looking at Elixir code. I think I've gotten used to it now. Looking at my own code, it's definitely more terse than it used to be. I do usually move such things into a separately named method, or a lambda that's assigned to an appropriate named variable. I do agree with you though, when you get a screenful of ampersands that contains non-trivial business logic - it's not great.