You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
for and while loops aren't common practice anymore and difficult to grok #312
I'm coaching somebody and we're going through the first few javascript tutorials.
And in those tutorials you have quite a few for and while loops.
In reality you don't really need for and while loops anymore, also they are much harder to grok than their functional counterparts. I'd recommend and would be happy to help creating tutorials to use array methods like forEach and map.
@juliankrispel I think we should keep the for loop at least as that is still a common construct one might see in code from time to time. I'd introduce a section on other ways of achieving the same effect such as forEach and map.
@matyikriszta I disagree. It's not a very common construct. In my experience if you look at any sane/modern codebases for and while loops get rarely used. I don't think it's appropriate as one of the first tutorials because forEach and map are easier to wrap your head round. JavaScript has changed a fair bit and I think it'd be good to update the tutorials to reflect common practices and discourage bad practices.
Hi @juliankrispel, thanks for submitting an issue! I've just been chatting with @oliverturner about this. You're right that JS has changed a lot, and I’d like to see forEach and map taught earlier. However my instinct is that for (and while?) loops are still common enough and have enough valid use cases to be worth teaching.
Oliver's Hot Take:
We should teach both styles because they're both in the wild and need to be understood. Additionally, we should add the caveat that for loops are mutative (and what that means / why it's considered better not to).
Also I’m not so sure that forEach/map are easier to learn first. It's true that for loops have complicated syntax and introduce bad/imperative habits, but forEach/map require you to introduce array methods and get your head around things like functors. I’d be surprised if forEach were easier to understand right away.
I'd be interested to see how codecademy etc handle the topic in their beginner JS tutorials.
Activity
KimberleyCook commentedon Sep 27, 2016
We would very much welcome this update, it's something we've been meaning to do "for" a "while" LOL 😂
KimberleyCook commentedon Nov 3, 2016
@juliankrispel Are you still interested in updating our tutorials?
juliankrispel commentedon Nov 3, 2016
Absolutely. Will have a look next Tuesdayat codebar
Julian Krispel-Samsel
rainforestqa.com
goodafternoon.co
matyikriszta commentedon Nov 7, 2016
@juliankrispel I think we should keep the
forloop at least as that is still a common construct one might see in code from time to time. I'd introduce a section on other ways of achieving the same effect such asforEachandmap.@KimberleyCook what do you think?
juliankrispel commentedon Nov 7, 2016
@matyikriszta I disagree. It's not a very common construct. In my experience if you look at any sane/modern codebases for and while loops get rarely used. I don't think it's appropriate as one of the first tutorials because forEach and map are easier to wrap your head round. JavaScript has changed a fair bit and I think it'd be good to update the tutorials to reflect common practices and discourage bad practices.
richardwestenra commentedon Jan 19, 2017
Hi @juliankrispel, thanks for submitting an issue! I've just been chatting with @oliverturner about this. You're right that JS has changed a lot, and I’d like to see
forEachandmaptaught earlier. However my instinct is thatfor(andwhile?) loops are still common enough and have enough valid use cases to be worth teaching.Oliver's Hot Take:
Also I’m not so sure that
forEach/mapare easier to learn first. It's true thatforloops have complicated syntax and introduce bad/imperative habits, butforEach/maprequire you to introduce array methods and get your head around things like functors. I’d be surprised ifforEachwere easier to understand right away.I'd be interested to see how codecademy etc handle the topic in their beginner JS tutorials.