How to Talk About Loops

Right now I’m putting together videos on loops, and it has really got me thinking. What is the best thing to teach here? The path of least resistans feels like starting with forloops, then perhaps while, and then foreach. That’s how I was introduced to the concept. That’s sort of the safe and comfortable way.

But could you just as well start with foreach? Or why not even map? How would your programming world be if you started out on a functional road from the beginning. I don’t like for loops, and I don’t think I’ve ever written a while loop, so why should I teach them.

This time I took some sort of middle road and started with foreach, and then talked about for and while. I think that id I’d do it again I would totally skip the while loop.

But I also think that map is harder to explain to someone new to programming. Or perhaps that’s just because I was started with it the other way around.