Typing something out and pasting it produce identical files, so the argument for typing has to be about what happens to you rather than to the code. It is a real effect and it is narrower than the traditional advice suggests.
What does typing actually do?
It forces sequential attention. You cannot type a line without processing each part of it, where you can paste forty lines having read the first three. The attention is the mechanism rather than the keystrokes.
It also builds fluency with syntax, so that the mechanical parts stop consuming thought.
Why does syntax fluency matter?
Because anything you have to think about takes attention from the problem. Somebody who has to recall how to write a loop has less capacity for the logic inside it, and that capacity is limited.
Getting the basics automatic is what makes harder work possible, and it comes from repetition.
The evidence for the effect is more mixed than the advice suggests, and the mechanism that clearly holds is attention rather than anything about muscle memory. That is worth knowing because it tells you what to preserve: the careful processing, not the keystrokes for their own sake.
What deserves typing?
- Anything using a concept you are learning.
- The core logic. The part that does the actual work.
- Anything you would struggle to write from memory.
- Code you will need to modify later.
Reading what you pasted before running it is the minimum in either case, since the attention rather than the mechanism is what was ever doing the work.
What is fine to copy?
Boilerplate you understand and will never change. Configuration, standard setup lines, import statements and anything that is identical in every project of that kind. Typing those repeatedly builds nothing.
The test is whether you could reconstruct it if you had to. If yes, copying costs nothing.
What about copying with modification?
A reasonable middle position and frequently the most efficient. Paste it, then change the variable names, restructure a section and add something. The modifications require the same attention as typing and produce a working result faster.
Does retyping generated code help?
More than reading it, less than writing it yourself. The useful version is to read the generated code, close it, and type your own version from memory, which is a retrieval exercise rather than transcription.
Show me how you would do this. I am going to close it and write my own version, then show you mine and ask what I missed.
What about handwriting code?
Genuinely useful for learning and terrible for producing anything. Writing an approach on paper before touching the editor forces you to think it through without the safety net of running it, which is a different and valuable exercise.
It is also what technical interviews frequently require, which is a smaller argument.
How long does this stage last?
Until the syntax stops requiring thought, which is a few months of regular practice. After that, typing everything out is a habit with diminishing returns and copying becomes entirely reasonable.
Does dictating code count?
It sits between the two and closer to typing than to copying. Speaking code aloud requires the same sequential processing as typing it, so the attention effect is largely preserved, and the syntax fluency is not.
For anybody who struggles to type comfortably this is a reasonable trade rather than a compromise, since the attention is where the learning is and keyboard speed is not a component of programming ability. What is worth keeping either way is the requirement to produce the code from your own understanding rather than to approve somebody else's version of it.
What is the honest position?
Type what you are learning; copy what you have learned. That line moves as you improve, which means the question is worth revisiting occasionally rather than answering once.