4 ms·
To take your argument to the extreme, why have for loops, when then are syntatic sugar over while loops? I'm generally a fan of syntatic sugar in a language if
by LordN00b 4y ago
To take your argument to the extreme, why have for loops, when then are syntatic sugar over while loops?
I'm generally a fan of syntatic sugar in a language if it's purpose is to simplify what's already there; but it is a balance between developer productivity and ease-of-use.
I once saw javscript described as 'pithy', becuase of it's small syntatical footprint, that's probably not true so much now.
- ptx 4y agoI believe Crockford said in a talk [1] that he was going to stop writing loops when tail-call elimination is supported everywhere. Also, avoiding the for loop in JS might be a good idea because of how easy it is to shoot yourself in the foot with "for (x in stuff) ..." creating a global variable (when you accidentally leave out "var"). [1] Probably this one? https://www.youtube.com/watch?v=XFTOG895C7c https://www.youtube.com/watch?v=XFTOG895C7c
- kwertyoowiyop 4y agoIndeed. Just as with real sugar, a little syntactic sugar is great, but too much is icky.