I'm on board with this, but my background in learning to code was a little different. My Java instructor (first formal programming class, but not first language) took the approach that teaching to code should imitate real things. So, our first few programs were around modeling real things in the world. We wrote a program to figure out why 7 was the most common number in gambling by rolling two virtual dice several thousand times and plotting the results. We explored the Birthday Paradox by randomly generating numbers between 1 and 365 until we hit a duplicate, and repeated that several times to prove the range. It was a great approach, and one that stuck with me.