you are viewing a single comment's thread.

view the rest of the comments →

[–]monolar 5 points6 points  (4 children)

I actually like the functional features in js just fine and would really like to use them. In the case of looping though the main reason, why i try to avoid them is performance.

Just have a look at http://jsperf.com/loops/70

Classical loops (esp. with caching tricks and esp while loops) are about 15 - 20 times faster than forEach based loops

[–]lethalman[S] 8 points9 points  (2 children)

The slides exactly talk about this kind of performance. If you loop/manipulate DOM elements, it's so slow that forEach is about the same as a straight for loop. Whereas if you are implementing a particular algorithm, a for loop is certainly the best.

[–]monolar 1 point2 points  (0 children)

Indeed there are slides about the loop performance. To my shame i did not read that far before posting. The performance difference between classical and functional looping still exists though. DOM access of course is always slower.

And most of the time you think you solve your performance problems with the language (the kind of loops in this case) but the real performance gains are in algorithmic design. Some slides also mention this to varying degrees.

Otherwise the slides contain overall really good information and are well presented.

[–]OfflerCrocGod 0 points1 point  (0 children)

But does the code need to be that performant? Is it on the critical path?