To me, it's understanding how to think precisely enough about what you are trying to do.
Syntax comes pretty quickly, but it's the precision that is hard. So, for example, even writing a simple loop. Are you going to start at zero? Are you going to start at one? Should your loop condition be at the top of the loop, or at the bottom? Do you know what each of those implies about how many times the body of the loop will be executed? Do you check the termination condition with less than, equal to, or both? Are you sure the loop will terminate? Really sure? Do you know at what point any variables declared inside the loop are initialized, or re-initialized? Are you adjusting the loop variable inside the loop body in a way that is going to mess with the loop termination?
Programmers think of things like loop pre-conditions, post-conditions, and loop invariants to help them keep track of what they are doing, but beginners don't usually have tools like this that help them run the code in their heads while writing it to help ensure it will do what they intended.
As an example of just how easy this is to screw up, consider examples of unintended infinite loops:
Syntax comes pretty quickly, but it's the precision that is hard. So, for example, even writing a simple loop. Are you going to start at zero? Are you going to start at one? Should your loop condition be at the top of the loop, or at the bottom? Do you know what each of those implies about how many times the body of the loop will be executed? Do you check the termination condition with less than, equal to, or both? Are you sure the loop will terminate? Really sure? Do you know at what point any variables declared inside the loop are initialized, or re-initialized? Are you adjusting the loop variable inside the loop body in a way that is going to mess with the loop termination?
Programmers think of things like loop pre-conditions, post-conditions, and loop invariants to help them keep track of what they are doing, but beginners don't usually have tools like this that help them run the code in their heads while writing it to help ensure it will do what they intended.
As an example of just how easy this is to screw up, consider examples of unintended infinite loops:
https://en.wikipedia.org/wiki/Infinite_loop#Examples_of_unin...