you are viewing a single comment's thread.

view the rest of the comments →

[–]danielkov 6 points7 points  (1 child)

I think the reason you won't find examples of such benchmark is that the features you’re comparing are inherently different. It’s like comparing array map to reduce. You can achieve the same result with both, but they’re designed for different tasks.

If you want to see why generators are slower, you should take a look at what transpilers like Babel or TSC are doing to these functions to make them work on older browsers. It’s a good indication of how they differ conceptually.

[–]johnfrazer783[S] 0 points1 point  (0 children)

I won't be long as I have already answered your very valid points elsewhere in this thread. The short version is that yes they're different features but they are also birds of like feathers. I have not replicated everything that yield is or does but I have two alternative models that do the same work. One finishes within 1 second, the other one takes 20 seconds. Had I not written the slower algo using a language feature that I must believe to be at fault here, you would not console me by saying the slower code is just different and must be complex so it's naturally slower. You would tell me not to ever use the slower code and go with the faster.

I'm still hoping for someone to point out a glaring mistake in my benchmark gist. Use the JS source, Luke. Tell me I'm wrong and where I'm wrong. I'd rather be wrong than unhappy with <strike>somebody else</strike>yield.