I suspect it's time to digest the concepts and when it's slower to handwrite versus type that results in better comprehension.
Daniel Oppenheimer et al.: Fortune Favors the Bold (and the Italicized): Effects of Disfluency on Educational Outcomes (Proceedings of the Annual Meeting of the Cognitive Science Society, 2010), https://escholarship.org/uc/item/4wd1s7hj
"Study 1 found that harder to read fonts led to increased retention in a controlled laboratory setting. Study 2 extended this finding to real-world classroom environments."
I'm not an expert on this topic, so I don't know whether this result was replicated since. If it indeed works, then kudos to my university's physics department for making use of this effect - they had a habit of handing out physics cheat sheets and various MATLAB code snippets that have been photocopied for 15+ years from one copy to another.
For some of my undergrad courses we were allowed a 'cheat sheet' which is a single 8.5"x11" sheet of paper that we could write anything we wanted on and could bring in to the exam. It became a skill to carefully put an entire course's worth of information on a single sheet. But for me, interestingly, once I had made this sheet I rarely referred to it in the test. The act of making it was enough for me to remember most of it.
For me, yes. It's a question of speed. I type much faster than I can handwrite. For a complex unit of code, it's better for me to dump it as fast as possible so I can hold it in my mental pipeline as a whole.
Long ago, learning touch typing was a huge boost to my programming capacity.
For other stuff, I find it better handwritting so the ideas have the time to sink in. Programming seems a more complex activity.
When learning to program, I found typing out code samples had a similar effect to writing them out by hand, and felt more natural to the domain. But in other subjects in school, it felt like my comprehension was lower when I typed lecture notes instead of handwriting them. I was never sure whether that was something inherent to hand writing vs typing or it was just because I had more of a barrier between typing and thinking than I did with handwriting.
It always seemed clear that the value of writing something verbatim was that it forced your brain to internalize it in a way you don’t need to when reading. It takes longer to hand write than to type — maybe that is the value of hand writing vs typing? Or when typing I needed to think more about the act of typing, whether that was thinking about formatting/positioning or just being less natural than handwriting? Maybe programming is just a special case where you always think through typing?
I lean towards thinking it’s somewhat domain specific. Clearly with physics or math if you had to typeset equations with LaTeX that would get in the way, and typing would be a barrier to understanding. With programming, every idea is expressed through typing, and so typing is a natural way to imprint ideas on your brain.