I had the same question when I wanted to learn C++. I was already quite practiced at Java and had written C and had read books on C++ off and on for years, but I still could not program in C++.

So I got a copy of Stroustrup "The C++ Programming Language" and started to do his exercises, but the author clearly had never done them himself, some were quite long and tedious and did not teach me anything (never put exercises in a book that you have never done), so I gave up on doing his exercises.

In my exasperation I just made up my own exercises: I just started at the beginning of the book and for each feature the book mentioned I wrote a little program that used it. The book said you can throw any kind of object, including, say, an int, so I wrote a program to throw and catch an int. I have never done that before or since, but I did it. I wrote a little program for every feature of the language. It was incredibly tedious, but it worked.

I also compiled every program with two C++ compilers and ran them and compared the difference. Many of my little programs did different things in the two compilers (!). I coded for 10 hours a day for two weeks; when I was done, I could code in C++, I could think in C++. Don't despair if it takes you longer: recall that I was already an experienced programmer.

SECRET SAUCE HERE: The key here was to actually write the program even if I was sure I had nothing to learn from it because the feature in question was so conceptually simple: you think you know something, but then when you go to actually type it in, you find out whether know it was well as you thought you did. The tiny improvements you make while doing this copy-check-repeat feedback loop is the essence of learning the skill.

Note that no mistake is too small to be worth correcting. It is critical to not say you have passed the exercise until you can produce the result exactly and reliably, as a matter of course. If you just wrote a program and it was easy, then hide it and write it again.

At one point I was embarrassed that I could not write makefiles, so instead of copying them and hacking on them, every time I needed one I wrote it from scratch; now I am a master of gnumake. I repeatedly write fizz-buzz, binary search, heapsort, hashtables, etc. over and over, just to make sure I can do it correctly and without effort.

One of Richard Feynman's wives left him, legally accusing him of spousal abuse because he did too much c1alculus: https://www.theguardian.com/science/2011/may/15/quantum-man-... '"He begins working calculus problems in his head as soon as he awakens," Bell complained to a divorce judge. "He did calculus while driving, while sitting in the living room and while lying in bed at night."'

Ben Franklin describes using this method in his autobiography of how he taught himself to write. He dropped out of second grade and ended up as one of the best writers in American history (not to mention scientist, statesman, engineer, etc.) He says he found writing he liked and practiced copying it and then checking that he had copied it correctly; see his autobiography for more.

Woz used this method to teach himself how to build computers: he had the designs of computers from Silicon Valley firms and he just practiced rote copying the designs over and over.

I tell you this as a former graduate student in Mathematics at Berkeley: The secret to learning is not reading a bunch of abstract ideas. The secret is just running a huge number of examples through your brain; your brain then abstracts them for you. There is no need to study a bunch of abstract rules. After you have learned the skill this way, doing a "master class" with an expert where you return to what you have learned and examine it, think about it, refactor it, can also be helpful. However do this after you have the skill. The standard advice in Zen practice is the same: "practice first, study later".

If you think that this cannot possibly work, then think of how you learned to speak your native language; did someone explain the rules of the grammar to you as a baby, or did you just rote imitate it? Non-native speakers of English have asked me why a feature of English is the way that it is or what the rule is for a certain situation in English. I tell them I have no idea.

Our school system lies to you completely. LEARNING A SKILL IS NOT ABOUT THE CONCEPTS, IT IS ABOUT ROTE MINDLESS IMITATION UNTIL YOUR BRAIN HAS INTERNALIZED THE IDIOMS. Your brain cannot memorize the massive amount of detail in all of the examples, so it must abstract them into idioms; once it has done that, you simply have the skill and you do not even know how you do it yourself. How exactly do you approach a door and open it? If you think you know, then please explain it to the teams of people at places like MIT who are trying to build a robot that can do that, because it is very complex. You do it and you do not even know how. But you can do it.