4 ms·
Eh. It reminds my of writing vectorized mathematical code in numpy or matlab. Oh it's so much cleaner because you don't have an ugly loop! If all you have is a
by patrick451 5y ago
Eh. It reminds my of writing vectorized mathematical code in numpy or matlab. Oh it's so much cleaner because you don't have an ugly loop! If all you have is a basic dot product, sure. But a lot of times, a loop is a hell of a lot easier to understand, even if it is slower.
Almost universally, I find the map/reduce/filter idioms to be inscrutable, write-only code compared to a good old loop
- dnautics 5y agoHere's some real code from our work system (variable names have been changed): invoice_id |> Audit.get_entries() |> Enum.map(fn entry -> entry.action end) |> Enum.map(fn action -> to_string(action) end) |> Enum.join("\n") Tell me you can write that as an "easier to understand" set of loops. Tell me that this code is "write-only" and that you don't immediately understand what is happening, without even knowing the language it's in.
- valzam 5y agoThe pipe operator really is elixirs secret sauce. The whole OTP platform amazing but web servers can live without it. But the developer ergonomics of the pipe operator for code that is to a large extent 1) accept input 2) parse input 3) transform input 4) store input Is just amazing
- patrick451 5y agoYes, I'll go ahead and say that. I have no idea what this does. It would be a lot clearer as loops.