In the case of teaching programming skills - that is the main goal, for students to learn how to program and improve their computational thinking skills. Just like when teaching writing skills, reading skills, speaking skills, time management skills, etc.
One of the biggest problems is we try to teach these skills without context. You learn some procedure or concept and you're supposed to just memorize it and apply it sometime later. Instead, we should start with the context. Making a game, for example, or creating an app or website that serves some relevant purpose or solves some real-world problem. This is the idea behind problem-based learning, service learning, and the like. It also can be more effective to teaching programming in the context of other school topics, like math, science, etc. Here's one example: https://edsource.org/2016/teaching-math-with-computer-progra...
And here are a couple of relatively recently summaries of some research in computer science education, but there's a whole field of research on the topic, with conferences and journals and books every year. https://computinged.wordpress.com/2012/05/03/blog-post-999-r... http://cra.org/ccc/wp-content/uploads/sites/2/2015/01/CSEdRe...