Tips for Self-Learning Programming

My friend who’s learning programming asked me the other day: ‘What do you recommend for learn programming quickly?’. I learned programming by myself when I was in college, and over the years I’ve realized how I went about it in the hardest way possible. There are many things I could have done to learn at a much faster rate. Hence, I thought I’d look back and write down some of the things I’ve learned over there years about learning programming.

‘Quickly’

I really like the original question, but I don’t know how I feel about ‘quickly’. I think that by following the advice below, you’ll learn programming fairly quickly (at least your growth/progression will be fast). But you shouldn’t really try to hack your way around it. Trying to hack it or fake it will come to bite you in the ass later on. The only way to learn ‘quickly’ that is actually sustainable is perhaps taking the language immersion approach. Find a way to immerse yourself into programming for an extended period of time (months?). In order for this to work, you need to be constantly pushing yourself to learn new things and get unstuck quickly. This is one advantage of coding bootcamps. You won’t be an expert when you come out, but you’ll learn much faster. This can be replicated through having a dedicated mentor or learning with a dedicated group of beginners.

1. Read > Write Code > Read > Write Code (on a daily basis)

The first piece of advice I would give to efficiently learn how to program is to go back and forth between reading about code and writing code. Reading about code (books, blog posts, open-source code) will help you see solutions, understand best practices, and get a general understanding of a language or a system. But after you do that, you need to actually go and write code. It can be anything. It can be little coding exercises or side-projects, but make sure you put that into practice and somehow use what you’ve learning. If you don’t do that, then you will find yourself in front of an editor having no idea what to do.

The trick here is for it to feel uncomfortable. This is rather painful, but that’s how it should be. Coding follows the 80/20 rule. You spend 80% of your time on 20% of your code or 20% of what you’re learning. Getting using to this uncomfortable feeling and overcoming it is key.

This iteration cycle should happen, not on a week by week basis or on a month by month basis, but on a day to day basis. The more you wait to use those skills, the more they will dull out. The more you wait to learn something new, the more missed opportunities you’ll have to incorporate that into your code.

The site I recommend to start reading about general programming topics is lobste.rs. They have a huge variety of articles on many programming topics. The other good site is Hacker News, but sites tends to go off-topic fairly frequently.

2. Don’t get stuck. Ask for help

My biggest mistake when learning how to program was getting stuck for too long. I would spend a lot of time being stuck on something either silly or something that I fundamentally did not understand. It would sometimes take days for me to get over some of these and I could have done some much more with my time and learned so many more things if I had just found better ways to get unstuck. Basically, getting stuck for more than an hour on something is almost always a waste of time.

I recommend three things for getting unstuck. The first one is trying to always read more about the technology you’re using and getting a general grasp of what’s going on. Usually, when you’re stuck it means you are making incorrect assumptions about something that need to clarified. Second is consulting the internet. This one is pretty obvious but worth mentioning. Looking up online for people who have this problem is a hugely important skill. Stackoverflow is arguably the best site on the internet for this. Don’t be afraid to actually ask your own questions in there. Often, just trying to correctly formulate your questions is extremely helpful. I wish I had done that a lot more in the past, but was always to afraid that my questions would be stupid. My third suggestion is just asking someone you know for help. Often, you might understand the technology and have a question, but you might need higher-level context in order to really get unstuck. Always go ahead and do ask someone.

When learning Docker, for example, I spent a RIDICULOUS amount of time re-building images from scratch. I fundamentally did not understand the docker cache and would spend 20 minutes waiting for a single change to a Dockerfile to come through. I probably spend 8 hours just waiting for builds. If I had just read up a bit more on Docker or asked someone who knew, I would have understood this and probably learned a lot more in a shorter amount of time.

3. Work on projects

In my experience, there is nothing as helpful to learning programming as working on your own projects. With some exceptions, all the really good programmers I’ve ever known have a habit of working on side projects (which can happen at work too!). Having an idea and trying to implement it is incredibly challenging. It takes a lot of discipline. But, by trying to actually make something, you learn how to break down a problem and apply technology to it. The sort of problems that you face and how you get around them is really what programming is all about. Knowing every quirky detail about a programming language will help you, but it’ll only get you so far. Also, the drive to want to finish your project is what will give you the motivation to keep learning. The satisfaction you get from a side project is much more than the satisfaction you get out of learning about things in the abstract.

My advice for picking side projects to work on would be to pick something that interests you, but also something that you’d have an idea how to implement. Being able to articulate implementation before starting was always helpful in keeping me motivated. You’ll definitely learn a lot along the way!

4. Recognized the difference between deep diving and hacking. Pick accordingly.

There are two types of programmers: perfectionists and hackers. Some people want everything to be just right, they want it to be perfect, they want it to follow all best practices and write beautiful elegant code. They want to understand every single line of code. Other, just want the thing to fucking work, even at the detriment of the codebase. Balancing these two skills is really important. Sometimes you SHOULD make it deep dive into a problem or project and see what’s going on. Sometimes you should just get it to work, even if you have no idea what’s going on.

Whenever you’re spending too much time on something thing to yourself: Which approach should I be taking? For the most part, you want something in the middle. You want to provide a good, solid solution that you understand and can modify confidently, but that didn’t take an absurd amount of time. As you grow as a developer, you’ll get a better understanding of when it’s OK to just leave as it is, and when something needs to get be done a certain way.

Personally, I like thinking about getting my projects 80% perfect. If your project is absolutely 100% perfect and there’s no single line of code you’re embarrassed about, you probably spent too much time on it.

5. Talk to other programmers

One really good way to learn about programming is just talking to other programmers. You don’t have to talk about anything specific. Maybe something you’re learning, something that you think is cool, something you’re working on. You won’t find a lot of programmers who don’t love just taking about programming. Through doing this, you’ll probably learn a lot about libraries, services, programming languages, and patterns. But, most importantly, you’ll learn how other people think about programming. You’ll see that things you take for granted or had never considered are very different from person to person.

If you have nothing to talk about, just fall back to editor wars or tabs vs spaces.

6. Try everything. Wait 6 months if you don’t get it.

Finally, one thing that kept happening to me over and over is that I tried a lot of things I just did not understand. After trying something new for 30 minutes, I would stop. I think this is pretty normal when you’re starting out. But, I remember many times when 6 months later (or 3 or 9), I would come back to the same problem or technology and figure out how to use it. This was caused in part because I had some knowledge I did not have before, or because it was just frame in a different way. But waiting some time and then coming back to something is always one of the most helpful things you can do.

An example of this is learning how to use the terminal. I remember for a long time being afraid of the terminal and never knowing how to use it. It took me a while and small incremental steps to start using it regularly and understanding it. Granted, this would have never happened if I had known someone who could have explained it to me or would have found a good resource to learn it!

Conclusion

These are some things to help any new comer on their long, long journey to learning programming. I know I still have a lot more to learn and will continue learning how to learn forever. The most important thing though is to just keep going and not give up. This is easy to say, but learning programming can be very frustrating sometimes! Don’t worry about it. It’s normal.

Good luck!