News for hackers. Stuff that matters.
Re:Crafting Functions by cultus on Wednesday October 14, 2020 @05:00PM (#24781545)
I really disagree that composition is error prone. It makes it easier to test and isolate errors by easily allowing different implementations along the pipeline. You get abstraction and it's less error-prone. Abstraction usually is a win for reliability, because abstraction means less information and less entropy.
Re:Crafting Functions by marcosdumay on Wednesday October 14, 2020 @05:28PM (#24781830)
Notice that the post is written in Javascript.

Abstraction and composition are great to surface the main characteristics of your algorithm. A compiler then can take those characteristics and verify if they make sense. Different compilers can do that in different amounts, and the Javascript one does the absolute minimum possible. On this case, you get no safety, just more complex code.

Go ask a Haskell developer and the first reaction you will get is probably "wait, you were running getData inside the original function?!"

Re:Crafting Functions by remexre on Wednesday October 14, 2020 @09:25PM (#24783771)
> Go ask a Haskell developer and the first reaction you will get is probably "wait, you were running getData inside the original function?!"

Haskell developer here, this was indeed my first reaction :P

Re:Crafting Functions by tluyben2 on Thursday October 15, 2020 @10:29AM (#24788992)
It would be more interesting to see these things in multiple languages so it shows how it would be done (best) in those. Learning things js centered is is not good for everyone.
Re:Crafting Functions by stopachka on Wednesday October 14, 2020 @08:25PM (#24783396)
Hey team, author here:

I agree with the statement that composition won't make the code unreliable.

When I wrote mistake, the kind of mistake I was referring too was a mistake in abstraction boundaries, rather than execution. (for an extreme case consider a DSL: if you abstract a DSL from only one example, you'd likely get the core abstractions wrong)

Re:Crafting Functions by nendroid on Wednesday October 14, 2020 @05:20PM (#24781745)
He used javascript so he's probably talking about composition without type checking.

But yes more important then just composition is to use combinators and segregate your combinators from IO.