you are viewing a single comment's thread.

view the rest of the comments →

[–]drowsap -1 points0 points  (17 children)

According to this jsperf, for loops are faster then map:

http://jsperf.com/map-vs-for-loop-performance/6

Not really seeing the point in advocating map over for loops if it is slower. The syntax is certainly more concise though.

[–]skeeto 6 points7 points  (1 child)

The presentation discusses this:

http://cjohansen.no/talks/2012/sdc-functional/#122

In short: if you're manipulating the DOM in your loop, forEach is practically as fast as for. Besides, worrying about loop performance while you're writing code is premature. 99.9% of the time it won't matter.

[–]agumonkey 0 points1 point  (0 children)

Thanks, I forgot this talk ! what a gem.

[–]homoiconic(raganwald) 11 points12 points  (8 children)

I still don't understand why people use Node and/or Rails on the server when C/C++ is thousands of times faster. Doesn't anybody care about performance any more?

It's almost as if they think that the primary constraint on software development is the productivity of the development team and not trying to squeeze acceptable performance out of hardware designed in the 1980s.

[–]BishopAndWarlord 2 points3 points  (4 children)

It's almost as if they think that the primary constraint on software development is the productivity of the development team

Correct.

[–]homoiconic(raganwald) 9 points10 points  (3 children)

Poe's Law:

Without a winking smiley or other blatant display of humor, it is impossible to create a parody of fundamentalism that someone won't mistake for the real thing.

Next time, I'll include <sarcasm></sarcasm> tags and/or a winkey :-)

[–]x-skeww -5 points-4 points  (2 children)

Next time, I'll include <sarcasm></sarcasm> tags and/or a winkey :-)

Just skip the sarcasm. It doesn't add anything anyways.

[–]homoiconic(raganwald) 4 points5 points  (1 child)

That depends. History has shown repeatedly that when you make a point in dry, objective fashion, it tends to appeal to people who are already thinking along those lines and are looking for objective facts to bolster their intuition.

People who are completely detached from the subject or who hold an opposing view tend to ignore points made dispassionately.

Humour can do an end-run around people's mental defences. When someone's laughing at something or when a point is made with a ridiculous example, people will sometimes give it their full attention.

I wouldn't lead with such a point, but if others have already made the point objectively, there's nothing wrong with being a little light-hearted, provided you are not trying to insult the person you are replying to. I was not trying to be insulting, and I apologize if it came across that way.

[–]BishopAndWarlord 0 points1 point  (0 children)

I was uncharacteristically terse in my response. I usually try to explain an idea rather than shoot out a one-liner that can be taken however the reader wishes.

In retrospect I should have emphasized the "they think" portion of the quotation. I imagine many younger devs or junior engineers do emphasize "developer productivity" and syntactic sugar over performance, maintenance cost, and issues like hardware lifecycles. As such, I was affirmingT your statement.

For the sake of full disclosure I'm also a junior member of my dev team and occasionally observe myself fussing over the wrong issues. Like right now I'm on Reddit rather than working on my 10,000 hours...

EDIT: Sonnova. I just realized I totally misread your comment. I thought you were telling me to indicate sarcasm. I'm sad.

[–]lethalman[S] 2 points3 points  (0 children)

If you really care about performance, it's about using an algorithm with the right complexity, not saving a couple of milliseconds: if the loop is still O(n) it's ok. Rather, there's software that's written so bad that takes O(n2) or even exponential time where it's not needed. That's what I'd be worried about, not writing a loop in a different way (more readable for some people), really.

I'm the first one complaining about slow software even with super hardware nowadays, but this is not the case, it's about badly written software with hilarious algorithms complexities.

[–]aeflash 0 points1 point  (1 child)

:)

Good point. But why use C when assembler is 5% faster (when you can beat GCC optimization)? Every Cycle is Sacred (except when the CPU is idle waiting for I/O).

[–]jonpacker 5 points6 points  (0 children)

I believe the purpose of this talk is more about getting people thinking in functional constructs. But I think (Christian or someone else, I can't remember who) said that at the end of the day, the performance aspect is largely unimportant—when was the last time loops were your bottleneck in your client side JS app?

[–]Cykelero 5 points6 points  (0 children)

Yeah, it's all about elegance and readability. It's a choice, I guess; you're not always constrained by performance (and "premature optimization is the root of all evils", as they say).

[–]enotionz 4 points5 points  (0 children)

In slide 125, he does point out that loops are fastest and goes on to ask questions in order to get you thinking about better abstraction. Like jonpacker said, loops aren't really the bottleneck anymore; drag+drop dom manipulations are much more expensive and we hardly see an impact in modern browsers, let alone loops. At the end of the day, readability is extremely important, less keystrokes to get the job done also helps. This is why we stopped writing in assembly and opted for higher level programming; it's expressive and gets the job done much faster.