Learning to program: How to master a programming language fast

I’ll write a summary about my experiences at this weekend’s TeXUsersGroup conference (#TUG2020) soon but today I wanted to share this post I had already prepared and scheduled: about ways to accelerate mastering a programming language. Of course, I can’t guarantee this will work for you and ‘fast’ is always relative. You can do a fast 3-day-binge but not really have mastered the language (obviously). Fast in terms of actual programming language mastery could mean a year or two, depending on your previous knowledge with programming. But enough of the disclaimers, let’s get to it!

Learn as you go

My first tip is to learn as you go, that means on the one hand that you jump into it without expecting from yourself to acquire all possible theoretical knowledge first. This ensures you get practice fast. It will let you use the language rightaway and only learn things you’ll actually use. That’s how I suggest you start using Linux by the way, too. You don’t need to understand everything straightaway. Content yourself with using some basic commands like you find them in a beginner’s tutorial. Start modifying. Then expand your skills one command at a time that you look up only once the needs presents itself. Then keep a list with the commands or typical useful programming constructs if you ever wanted to learn it by heart. But learning as you go also means: Make it a part of your everyday life and literally learn as you go: on the bus using a book or app. While waiting in line. At work. Just try to maxime your regular everyday amount of exposure and you will get in the hours much faster, thus reaching mastery much faster.

Learn by heart what you’ve understood in practice

This might seem a weird or at least very unusual tip. Who would still recommend learning by heart what you can (and will) websearch anytime you need it? Seems redundant, right?

“Why learn by heart?” you may ask. Many people don’t with programming. But as a language teacher by training, I want you to consider learning a non-machine language. Of course you could, in theory, hold a conversation without learning a single bit of vocabulary by heart, but it would be quite tedious to look every word up. Rote learning is bad, but it’s not bad for all types of learning. Nobody really questions its use for learning vocabulary and phrases for living languages. The point I’m trying to make is: If you don’t know the most basic expressions by heart, you’ll be really slow. You’ll find it harder to understand code you could understand if you had better command of its “vocabulary”. Only once you know the vocabulary can you really perceive the structure behind it. And also if you do some kind of class and should get quizzed to write code on the whiteboard. Do you really think you could complete a correct function in C without auto-completion on if you didn’t learn it by heart beforehand? I don’t think so and I can’t.

Run a web search to check out Stackoverflow. Learn about the command, function or package you’re using. Often the problem is that you’re trying to misuse somebody else’s code, thinking it must works otherwise than it was actually programmed to. Then make it your own, write it down somewhere and “learn the vocabulary”. After all, programming nowadays is so much about knowing libraries, so just knowing the basic language constructs is only the beginning of your journey. I guess even advanced users can still benefit from this approach to strategic programming education.

It was this learning by heart which also skyrocketed my LaTeX skills: At some point I got annoyed and embarrassed that I run a LaTeX blog but still had to look up so many things. Of course I knew the stuff I needed all the time (because I had learnt it by heart through overlearning and extensive repetitive usage) but many other things, I looked up every single time. This just gets annoying. You feel like an idiot and it costs time. It will hinder you if you want to code on a train without wifi connection, unless you want to use up your phone’s data volume. And it just makes you a less good user overall because your brain has no processing space left to think about all the things which would actually be relevant. I solved this problem by starting to write all my documents using LaTeX for a while. Nowadays, I sometimes use GoogleDocs for sharing or ease of use but mostly I have stuck with this habit. By just using LaTeX for everything, the rote learning process will happen automatically and much faster than you think. You just need to actively make the effort for a few days. No big obstacle, right? Especially given the future payoff.

Also, with learning in general, I have read that you’re more successful if you try to activate your own brain before looking things up (says Barbara Oakley, for example). So trying to recall programming constructs, i.e. learning them by heart, instead of always looking everything up, will in fact make you a better, more proficient programmer. And you will look really cool live-coding in front of colleagues who think you have some kind of superpower.

Learn complete working functions

The next tip is to learn complete working functions, also kind of learn them by heart. So to practice, choose a function. Not only the ‘function declaration’ but a few lines of code with the basic functionality in action. For example if you’re learning C strtok(), knowing the declaration won’t help. You need to know how it’s used. Search an as-simple-as-possible example from the internet or documentation. Rewrite it to be universal and use variables which makes sense to you.

Many seasoned programmers use variables made up of one character which can be really confusing to a newbie. Feel free to rename them in a way which makes sense to you. Then try if it still works before you put it on your cheatsheet. Maybe even print it out or make flashcards from it to practice on the go. Putting time into creating them (best even handwriting them) helps fix them in memory. Then start quizzing yourself. Open a text or code editor. Disable any auto-completion or suggestion features. Don’t look at the function right before you start. Now try to write it out and see how much you can remember. I did that myself with complete mini programs in C with a functionaliy to read in a line from the commandline. That’s quite a short program generally but long to write out by heart with no chance to get a glimpse of help. I included important basics like setting up arrays and strings dynamically. But I failed recalling these basics many times. Auto-suggestions (just like highlighting excessively in books or re-reading material to be learned) give you the false feeling that you know the material and have it memorized. Testing yourself like this is uncomfortable because you’ll fail hard. But that’s the only way you can learn and make progress fast.

Write a cheatsheet to memorize and track progress

My first language was XSLT where you really only need the few same fuctions over and over again in the beginning, so learning by heart wasn’t necessary for me. But with other languages, I think it does make sense. I read so many books, did online courses and online programming exercises like Hackerrank. But unless I save my solution, print it on a cheatsheet and memorize it, it’ll be gone like I’d never even done it. It’s the hard truth. This cheatsheet rote learning (starting from a function you tried out practically first), is the only efficient and strategic way to progress I could identify for leaerning to program so far. Maybe other people don’t need a strategic approach like I do. I don’t know. But I think many would have an easier time if they had a training progression to guide them. Plus, the cheatsheet resulting from your efforts is a great way to visualize your progress, what you can do and also give you hints at which parts you should tackle next. Like systematic training does, it helps you track results.

Do as much as you can

Of course I have a lot less time than I’d want to. I do my mini programming drill on Hackerrank every day. Some days I code for work. A few days a month I read in a programming books. I update my cheatsheet only irregularly, like every 1-2 months. But you can save time by adding newly learned items every day right after practice and only beautify once per month. If you’re in a formal training, you absolutely should at least once per month. And print it out to learn on the go! A structured approach to learning needn’t be super time consuming.

Conclusion

If you don’t have quick progress and mastery in mind, you probably don’t need to do all this stuff I mentioned. If you just want to get to know programming a little. But like I said in my new years resolutions post, we often think that we do more than we actually do on a regular basis. If you don’t take a strategic approach to progress, there won’t be much progress sadly.

The methods outlined in this post are probably very uncommon in programming or computer science education. They are more like methods to learn living languages. Maybe you think they’re stupid but you don’t have to try them out. The methods also aren’t easy. A lot of work is involved. But, here comes the probably most important tip for learning a programming language fast: There are no shortcuts. Learning it faster is only possible by putting in more targeted, goal-oriented effort and using a more strategic approach than other people.

Maybe this helped someone – if you’ve tried it out, I would be happy to learn about your experiences. Have you used a systematic learning approach to programming so far? If yes, what do you do and if no, why not?

Best regards,

the Ninja

 

Buy me coffee!

If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

 

 

I like LaTeX, the Humanities and the Digital Humanities. Here I post tutorials and other adventures.

One thought on “Learning to program: How to master a programming language fast

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.