It maybe a coincidence after writing this, I found this write-up by Beekey Cheung on teaching coding first then the computer science fundamentals.
It seem to align to what I'm thinking too, but I'm putting it at one step above where I don't just start with writing code, but play around with the application built with the language first. This allow me to experience with a lot of cool stuff other than just plain if/else and for loop syntax, coupled with some "Hello world", which easy to get you bored after sometime.
I put here what I wrote on my blog.
####
The first step in learning new programming language is to prepare the basic environment where you can freely try and experiment with the new language features and tools. Maybe because I'm not programmer type person, but more as tinkerer/builder, I hate learning the language syntax and stuff.
For years after I started "learning" Python, I can't barely write any Python code. But I have manage to try lot of Python cool apps because I have that environment for me to experiment with all Python based applications. All these cool apps that get me hooked to the language, not the syntax or whatever language features. And in my experiences, this is one reason why people failed to get hooked on the new language they want to learn. They started learning with some of the language syntax and eventually get bored, because not so much interesting stuff there. In whatever programming language, it's the ecosystem that made it lively, and where the real work happened.
Early this year, I made it a point to learn Go programming language. It's almost a year now and similar to my Python experience I mentioned above, I can't barely write any Go code. But I have an environment where I can try a lot of Go based applications, and this is the reason I'm still hooked to the language even I haven't manage to write my own code yet. Back with Python experience, I'd only manage to know Python and write Python code after I got my first Python job. That was years after I started learning the language.
The reason this work I think similar to when learning human language. To master the language, you need to practice it. And to practice the language, you need to be in an environment where the language being used. That's it, the environment. So instead of trying to understand the for loop or the class syntax, I spent time to understand how packaging and deployment work, so I can actually run the application for other people to make use of it.
So start to invest your time in having the environment first, whenever you want to learn any new programming language.