3 ms·
Basic point free style as described in the article is alright in javascript. Extreme point free style does not work in javascript, AT ALL!!!! Two reasons: 1)
by dustingetz 12y ago
Basic point free style as described in the article is alright in javascript.
Extreme point free style does not work in javascript, AT ALL!!!! Two reasons:
1) Find the bug: the table sort is glitchy. Is the bug in this suspicious line, or somewhere else? (Real line of code in a codebase I inherited, and yes there is a bug in it)
var sorted = rows.sort(_.unsplat(_.pipeline(
_.partial(_.map, _, accessor),
_.splat(comparator))));
2) I use React, so I can get away with a lot of really functional stuff since React is well suited for functional javascript. React is a great functional abstraction, but under the abstraction is imperative code. Imperative code means you need a debugger. When you write in a point free style, there's nowhere to place a breakpoint!
- CrossEye 12y agoIt is harder to debug points-free code. I find myself doing more debugging with `log` statements in a long pipeline than I do with other styles of code. On the other side, I tend to work with a few well-tested functions over and over and end up with fewer problems to debug when I work in a functional paradigm, points-free or not. On rare occasions, when I need to debug something that is difficult because it's points-free I simply add some explicit parameters, either temporarily to enable debugging or permanently. Points-free is nice, but should never be an overriding goal.