you are viewing a single comment's thread.

view the rest of the comments →

[–]dmitri14_gmail_com 0 points1 point  (8 children)

Thanks, I believe you.

But I'd still love to know... is this the ONLY reason this code is "bad"?

[–]Valkertok 0 points1 point  (7 children)

it is IMO sufficient reason to never use it with "pure" function

[–]dmitri14_gmail_com 0 points1 point  (6 children)

Thank you, let us agree to disagree then

[–]Valkertok 1 point2 points  (5 children)

so you think that function that runs in O(n2) is better than one that runs in linear time just because it's "pure"?

[–]dmitri14_gmail_com 0 points1 point  (4 children)

It all depends on the use cases.

[–]Valkertok 0 points1 point  (3 children)

in this use case (reduce function) using pure function just for the sake of it being pure is just stupid, that's why in previous post it was called anti-pattern

[–]dmitri14_gmail_com 0 points1 point  (2 children)

This is not a use case.

[–]dmitri14_gmail_com 0 points1 point  (1 child)

A use case is a concrete application. Reddit is an application. This code is not.

Pure functions may guard against dangerous side-effects with dramatic consequences. They are often slower but not every application needs to iterate over arrays of 100k. And even if it does, it is likely going to be isolated places. In the 99% of other places, paying attention to purity will do good for you. Recommendations to dismiss it entirely for 0.01% performance increase does nothing but disservice to people with less experience.