In mentoring engineers I've found that some are doing what amounts to advanced pattern matching. They memorize the syntax for a for loop but never really internalize what it does (they just seem to know write these letters if you want things to repeat). Not dissimilar to what I suspect LLMs are doing when they generate code.
By contrast when I write code I see in my minds eye what the code should do, tinker with it, formulate an algorithm, and only then do I try to translate what's in my head into syntax.
When asked how people can learn this skill (or get better at algorithms in general) I always say they should practice writing code by hand.
I've seen the same tutoring math. It's tough to get through, as it's a learning style that got them this far. Of course, not they are needing tutoring, so it's stopped working.
How does writing code by hand fix this? They can still write the same things from the same understandings. I've had some luck having people explain things to me, without looking at the code/math.
The value is in getting them to write down what happens step by step as their program executes.
Writing things by hand can just help facilitate that because it removes the ability to run the program and get the final result.
People can lean on their tools to 'guess and check' their work. Write a loop, run the program, and get an out of bounds error. They'll have learned oh this error means I need to subtract one from my loop bounds. And sometimes that works, though many times, it means there's an edge case they didn't properly handle.
When you only have pencil and paper and you need to explain to me what your code does you have to write down a representation of what's in memory and then how it changes step by step as the code runs.
I would be way too impatient to write code like this. It is hard for me to imagine how anyone could do this. I guess I do not really get this, it almost feels to me like people want to be hipsterish a bit. But of course I am likely wrong.
I have no citation, but I’ve been told that writing something out by hand stimulates different parts of the brain, as does explaining that thing out loud.
By contrast when I write code I see in my minds eye what the code should do, tinker with it, formulate an algorithm, and only then do I try to translate what's in my head into syntax.
When asked how people can learn this skill (or get better at algorithms in general) I always say they should practice writing code by hand.