3 ms·
> copying data needlessly and turning trivial stuff into a functional pipeline that is impossible to debug. You want your code to read top to bottom like the pr
by WastingMyTime89 4y ago
> copying data needlessly and turning trivial stuff into a functional pipeline that is impossible to debug. You want your code to read top to bottom like the problem you're trying to solve, if at all possible. If your call stack looks like map, fold, reduce you've introduced a ton of complexity, and why exactly?
Hard to follow code is mostly a consequence of point-free style in Haskell which is an heresy to be avoided at all cost.
ML typically uses a piping operator to compose code instead and that leads to top to bottom code which is extremely easy to read.
There is zero difference then between a map and a loop. Loops are not read top down anyway nor are function calls. It seems to me you are just more used to these indirections than other ones and are therefor blind to them. This leads to an argument which I consider a straw man personally.
- lixtra 4y agoI tried googling for an example[1] and had difficulty finding a good one. Do you have a link to a good one? [1] https://elixirschool.com/en/lessons/basics/pipe_operator https://elixirschool.com/en/lessons/basics/pipe_operator
- dpwm 4y agoHere is an example in ocaml, where |> is the pipeline operator: https://cs3110.github.io/textbook/chapters/hop/pipelining.html https://cs3110.github.io/textbook/chapters/hop/pipelining.ht...
- Chris2048 4y ago> Loops are not read top down anyway nor are function calls But their scope can be limited.
- christophilus 4y agoI'm reminded of the Kernighan quote / trope: "Everyone knows that debugging is twice as hard as writing a program in the first place. So, if you're as clever as you can be when you write it, how will you ever debug it?" This phenomenon seems to happen more frequently with FP or related tools and languages (RxJs abstraction soup comes to mind).
- wiseowise 4y agoThis sounds really cool, except it was written in 1978 and has nothing to do with modern realities of functional programming or tools. > RxJs abstraction soup comes to mind Merely a side effect of being implemented in a language that wasn’t really designed for it.
- jimbokun 4y agoIn my opinion it's just as true today as in 1978, if not more so, but functional programming can make code simpler to reason about and therefor debug.