Re:FP techniques that will help you write better JavaScript
by bil7 on Friday February 11, 2022 @08:44AM
(#30301369)
a better idea is to first use filter() to obtain a collection you can then map() over. So then you dont need to continue or break, the offending elements of the collection were already filtered out.
[ Parent
| on HN ]
Re:FP techniques that will help you write better JavaScript
by thfuran on Friday February 11, 2022 @09:09AM
(#30301646)
But then you're processing the whole list, probably defeating the point of breaking.
Re:FP techniques that will help you write better JavaScript
by appletrotter on Friday February 11, 2022 @11:54AM
(#30303682)
that's a performance optimization. you have other performance optimizations available often, with tradeoffs.
FP is a higher level paradigm so you might have to trade off with performance too
Re:FP techniques that will help you write better JavaScript
by thfuran on Friday February 11, 2022 @12:25PM
(#30304145)
>FP is a higher level paradigm so you might have to trade off with performance too
Then it can hardly he said be to unequivocally be better, can it.
Re:FP techniques that will help you write better JavaScript
by 0ldskool on Friday February 11, 2022 @07:44PM
(#30308842)
that's like saying high level languages cannot be unequivocally better then writing assembly, not doing your own memory management is bad, etc...
Functional programming is a higher level abstraction. If the underlying implementation is not well implemented/optimized then you could have bad performance while the opposite is also true.
Re:FP techniques that will help you write better JavaScript
by thfuran on Friday February 11, 2022 @11:14PM
(#30309884)
>that's like saying high level languages cannot be unequivocally better then writing assembly,
Yes, it is like saying that. At least, assuming by "cannot be" you mean "is not".
>not doing your own memory management is bad
No, it's not like saying that. Note how differently those claims are phrased.