Is there a semantic difference between
learn to code and
learn coding? Can both forms be used interchangeably?
I believe there's a slight difference. I'm going to explain by comparing learn to program with learn programming.
To learn to program means the student (or trainee) will learn how to write software. If the training is successful, the student will become a proficient programmer.
To learn programming, on the other hand, means the student will learn about programming. This might include, for example, programming principles, theory, and best practices. If the training is successful, the student will have a better understanding of the various nuances of programming.
There is a lot of overlap, no doubt, but they are not exactly the same thing (not in my mind, at least).
A programmer must learn to code. A software project manager might benefit from learning programming. After all, even if a manager never programs, such knowledge might help managers better understand the challenges faced by their programming teams.