Learning to code? You're probably doing it wrong.
Tags: learning, beginners, programming, tutorial
Published: 2023-06-02 16:01:57

I began learning to program when I was very young. Around age 8, I started with Scratch, a graphical programming language where you drag and drop colorful blocks in a physical layout to define behavior. It's crude, simplistic, and terribly limited. You can't make web requests, your program can't interact with any others, and you're essentially limited to keyboard and mouse input. It's a sandbox.

Nowadays, most people start learning to program with Python or JavaScript. These are powerful languages designed to be very easy to use (though they have many shortcomings that this article won't touch on), and there are dozens of frameworks making it fairly trivial to build full desktop applications, websites, mobile apps, games, server backends - anything you can think of. Supposedly.

These are mighty abstractions. Building these projects now takes less code and less thought than perhaps at any previous point in time, and that's a good thing. It means that the bar has been lowered, it means that developers are more productive than ever before (at least in theory), and it means that for any given project, you likely already have basic templates and building blocks at your disposal.

All of this power can give people the wrong idea, however. Starting off, with each tutorial claiming to be able to teach you Python in a matter of minutes, each framework showing off how quickly you can spin up websites in them, people get used to always asking the question "What can I do with this?" And while it's true that the point of technology is that it can do things, it ignores that technology is only as effective as its wielder is competent. Instead, you should always be asking yourself "What can I _learn_ from this?"

To a beginner, this is often the most difficult part. After all, you're having to learn new syntax, new rules, a new way of thinking, akin to (and perhaps more difficult than) learning how to speak for the first time. It can be grueling to get accustomed to this, especially when easy answers that glaze over the underlying concepts are at your fingertips with Stackoverflow and an endless supply of video tutorials.

This is the trap that most beginners tend to fall into when learning to code these days. There are so many resources online, so many tutorials that will teach you how to build your first React app or make your first game in Unity. Regardless of how good these tutorials may be, and how good of a job they do covering the fundamental concepts of programming, they instill in the beginner a certain mindset: Programming is about doing. 

But as a beginner, that is the last thing programming is about. I'm sure you have plenty of ideas for projects that you want to do, but the first thing to realize is how far-fetched they all are for someone who doesn't have an understanding of the fundamentals. Inevitably, you will run into algorithmic challenges in some part of your project, and if you are unprepared, these can seem like impassable barriers. You may not even understand what information you're missing in order to solve it, and this presents a real problem.

Help communities are often overwhelmed with individuals asking how to do things clearly far above their technical capabilities, and it can be difficult to get them to understand the scale of their skill defecit. Many of them are uninterested in the long road to mastery that they must walk before they can complete their projects, and charge forward expecting to be supported by experts who can hand-wave the difficult parts away for them.

So I propose this: Forget your goals. Shelf them. They are long-term goals at best. Your first and only goal as a beginner is to become an intermediate. It's often not clear exactly where the line between a beginner and an intermediate programmer lies, so I will try my best to draw it a little more clearly here.

A beginner programmer struggles with moment-to-moment programming. You can ask them to get the sum of the elements in an array and they'll likely be able to do it, either by Googling their way through it or by thinking hard enough. This is how it always is to a beginner: Choosing between the path of least resistance, which will allow you to accomplish your goal more quickly, or taking the time to write it out fully from your own head. I won't moralize about which is fundamentally superior, as both are a part of everyday programming tasks. Knowing when to do which is an important skill as well.

You become an intermediate when you gain fluency in programming. I don't care what language you learn, though you shouldn't limit yourself to just one. An intermediate developer, at least for simple tasks, can "just write the code". I can tell you to get the minimum element in an array and the amount of time it takes is limited by how fast you can type it out, not by how long it takes you to think about it or how long it takes to load Stackoverflow.

You can think about this in terms of a spoken language. As a beginner, you probably have to think about each word's translation, remember grammatical rules and consider how they should be applied, and then keep it all in your head as you're trying to build a sentence. At some point, it becomes natural, and you barely have to think in order to know what to say.

When you're starting out, your sole goal should be attaining this level of fluency. After all, if every minute task feels daunting, it doesn't matter how many tutorials you follow because you never gained a mastery of the fundamentals. Data types, functions, conditionals, and control flow are the most basic building blocks used in every programming language. Understand what they are and how to apply them, and you'll find that everything else follows more easily.

Getting there is no simple task, though. Likely this is why many beginners turn to tutorials: They're easy, and it certainly makes you _feel_ like you're learning. But really, you're typically learning how to use specific frameworks or how to make a button do something when you click it, while not fully grasping what every symbol in every line of code means.

It's demotivating. Motivation is a resource when you're learning to code, and it's easy to misuse. Following tutorials may take very little motivation, but it gives you very little in return. So use your motivation wisely, and try to make mundane things fun.

When I began coding in Scratch (and to this day), many of my projects were just experiments. Testing out the mechanics of the language, trying to build something that, while not useful on its own, might help me down the line or at least teach me something. I was a child, and this was certainly not intentional, but this curiosity-driven learning gave me a far better understanding of the basics than tutorials ever did.

Make a program that asks you what you're wearing, and then insults it. See what happens when you try to bend the rules a little. Read a book that discusses design patterns in your favorite language. When something doesn't make sense to you, keep poking at it and looking further into it until you understand every component at play. Stupid little programs that make you laugh can help make it feel less boring. You can make jokes in Python just like you'd make jokes in English, but to do that, you need to understand the conventions so you know how to subvert them.

It's also important to get involved with some kind of community. Every common programming language generally has at least one Discord server dedicated to it, and many have forums or other kinds of communities as well. Surround yourself with other people who are learning similar things, talk about what's blocking you, don't be afraid to ask stupid questions, and ideally, find a learning buddy. Learning alone is hard, and having someone who's interested in similar things, and holding each other to your learning goals, will help immensely. Make sure to seek feedback on your code from people more experienced than you, because they will usually be able to identify ways to improve it. This is one of the most fruitful ways to learn. Just try to keep your code snippets to 100 lines or less when asking for feedback, to be mindful of those who are willing to help you along your journey.

And for the love of god, read documentation. It can be dry, yes, but learn to check docs first and Stackoverflow second. This is going to be the part that you just have to grit your teeth and deal with, because reading docs never ceases to be an important part of being a developer. If you're curious and enjoy tinkering, as I do, reading docs may even be exciting. It will make you a far better developer than if you only read enough to have a shallow understanding which is just enough to complete the task right in front of you - and Stackoverflow generally provides just that.

It can be difficult to motivate yourself to do these things, because sometimes it feels like there's no end to it. Everyone will tell you that there are infinitely many things to learn about programming. How many languages? How many frameworks and libraries? How many different ways to perform the same task? These are countless, but in focusing on them, you miss the point. If you know how to write a loop in one language, then in the next language you learn, you will still know when a loop is needed, and even if you don't know how to write one, that's easy to find out. These fundamentals will stick with you no matter what language you're using, and a mastery over them will open the doors to whatever you feel like exploring.

Once you feel comfortable just writing basic code, making experiments, cracking a joke or two, you've done the hardest part. Many never reach that point, if only because they don't know how, or because it seems like such a daunting task that they don't try in the first place. It is undoubtedly difficult, but it is also an experience you will look back on fondly. Maybe someday you'll find it amusing that you once struggled to write a simple loop.