I was recently asked this question. As if that wasn't big enough, it was followed by, "What is the best programming language and best way to learn it?" I definitely can't tell you what the "best" language or learning process is, no one can. As for the rest of it? I can tell you how I found my way. This post aims to provide one possible path towards getting into and learning programming.
I want to begin with my story. I started with Python. I will not tell you Python is the best programming language. It happens to be what worked for me. The concepts explained in this post apply to learning any language, and, really, to learning pretty much anything.
My path to learning Python began with someone else in my life wanting someone to learn Django with them. That meant me learning Python first. Initially, I tried to learn it text-book style. I picked up the official Python tutorial, and started to work through it. It turns out, at the time (it's since been updated), the Python tutorial was written for programmers, i.e. folks who had programming experience in other languages, and was not designed for beginners. I did not know this, and when I began struggling pretty early on, blamed myself for not understanding it. I pretty quickly stopped trying, and thought that perhaps learning Python was not for me.
Around the same time, I had received my first Raspberry Pi, and immediately went online to buy a bunch of accessories because that's evidently what you do when you get a Raspberry Pi. Along with the Pi kit, I bought a Circuit Playground Express (CPX) microcontroller. I assumed it could interface with the Pi, and did not realise until I got it home that this was not the case. It seemed far too complicated for me, so I tossed it aside for 2 weeks. I felt bad because it was the most expensive thing I'd bought, so I eventually picked it up again, and tried to figure out what to do with it. I stumbled onto a mention of "CircuitPython", which it turns out was a version of Python designed to run on microcontrollers such as the CPX. I thought, hey, I'm trying to learn Python, this is perfect. I went about trying to get it going. It was still in its early days, so the experience was not nearly as smooth as it is now. I did, however, manage to get it going. I then wrote my first Python script, copied it onto the board, and made an LED blink.
Nothing I had done up to that moment captivated me as much as that blinking LED. I immediately wanted to do more. It turns out, not only was the programming language new, but so was the hardware. There was very little documentation. So, the first thing I decided to do was complete a project and document it so that others would have an easier time of it than I did. I offered to write a guide for it, and my offer was accepted. So I set out to create a light up, capacitive touch tone piano. I wrote the code for the project and got it into a place I was happy with within a couple of weeks.
As I worked on my project, I was encouraged to expand a very bare-bones helper library designed to make using CircuitPython with the CPX super simple. I thought this was ridiculous as I'd been programming for only a few weeks, but I figured why not, so off I went. The library I started with had five features included already, out of what would turn out to be an extensive feature-set. The first feature I added was the ability to play tones. I incorporated it into my project, and promptly broke my code. It became clear that I would have to implement all the features of my project in the helper library for it to work properly. Over the next month or so, I wrote what would become one of the most ubiquitous CircuitPython libraries.
I completed the guide, which, much to the surprise of a couple of folks who had helped me along the way, included some very basic coding concepts. Really, though, why wouldn't it? I wrote the guide for someone in my position, and I started from knowing nothing. It only made sense to include the most basic concepts I learned. The guide began with those basic concepts, and built on them to explain the final example code. On some level, most project guides I've written since then all follow that same concept. But none of them cover the absolute basics like that one does.
My story can be distilled into a series of steps. I decided I wanted to learn Python. I discovered that a text-book approach to learning it wasn't going to work for me. I eventually figured out something that was going to work when I found Python on hardware. I picked a specific goal of writing a project and documenting it, and used Python in part to meet that goal. I extended my knowledge by working on the library, which was still applicable to my project. I solidified my knowledge by documenting it. This process gave me a place to start, and helped me figure out how I learn best, which has made it easier for me to pick up other concepts as well. You can apply these steps to finding your path to programming.
Find something you want to do. This doesn't necessarily mean picking a programming language, though that is also an excellent place to start. This step is more about choosing a specific project or task that can be worked on or solved with programming. If you can't come up with something on your own, it's perfectly okay took through projects done by others. If you already have a programming language in mind, look into the types of projects that make sense for that language. Regardless of how you choose, make sure that it's something you find compelling. If it's not interesting to you, you won't stick with it. The key is to find a project you want to work on.
If you don't already have a preferred programming language, you'll need to pick one. Do a little research to figure out what programming languages are suitable to your chosen project. For example, if your project is data science related, Python would be an excellent choice. If your project is Android mobile development, Kotlin is a great place to start, though there are many other options for Android development. Basically, make sure that whatever programming language you're considering works for the project you've chosen to work on. Ending up with a language that is inappropriate to a particular project can lead to frustration, and ultimately, giving up. Ensure you're choosing the right tools for your needs to set yourself up for a positive experience.
Build your project. This is where your learning style comes into play. You know how you learn best. There's no way for me to cover every possible approach. I can, however, provide a couple of options. You can start fresh, and learn each of the necessary concepts to write each section of code. This can involve using resources from the ground up, learning the basics, and building on that knowledge. Alternatively, you can start with an existing project, break it down into pieces, learn about each piece, and use the parts you need for your code. This basically involves hacking apart existing code and figuring out how to fit it together for your needs. I learn the fastest using the second approach. As I mentioned earlier, the first approach didn't work for me, but it took me trying it to figure that out. It's up to you where you want to start.
Consider documenting both your code and the process. Documenting your code can be anything from comments within the code itself, to including a detailed post or README on the web. You'll want to explain what your code is doing and how to use it. Documenting the process means including your failures along with your successes! Sharing your successes can feel great. However, knowing that someone else experienced the same failure can make or break whether someone decides to continue working on something. It may seem awkward to share failures, but you could very well help someone else along the way, and reaching even one person makes it worth it. Further, documenting the process you used will help others who are working on similar projects. Keep in mind the little bits of information you gleaned from a variety of resources while you worked on your project, and strive to become a part of those resources for others in the future. Not to mention, documenting will help solidify the knowledge in your mind; you really need to understand a concept to be able to explain it to someone else.
You should also consider sharing your code. There are a variety of options available, each with their own set of steps necessary to post your code. If you're new to it, it will present another challenge in your programming journey. Rest assured, there is plenty of documentation available online for various ways of sharing your code. I use GitHub, but you'll find many other options available as well.
Once your project is complete, the first thing to do is congratulate yourself! You've learned at least a few new concepts, and you've put them to use. You completed a goal you set for yourself. Maybe you shared it with others. Fact is, you've completed a huge first step towards learning programming.
Now it's time to retain and expand on what you learned. You can pick a new project to work on, or a new set of concepts to learn. If you'd rather be working with others, you can find an open source project to which to contribute. It's important to choose a project that is prepared to help new folks along the way. There are plenty of projects that fall into that category, and it will ensure a positive experience for you. Regardless, the important thing is to continue using what you already learned, and work towards building on that to expand your knowledge. I find it very difficult to retain information if I'm not using it at least every so often, so for me, it's crucial to find an excuse to repeat a new concept. This is a pretty common phenomenon, so you should consider doing the same.
I want to be clear that this is not necessarily the best way to learn programming. I have some gaps in my fundamental programming knowledge because I learned the things I needed as I worked through my code, and some of the most basic programming concepts were never necessary. This means I sometimes struggle with what seem like simple concepts because I was never introduced to them. If you feel that it is crucial that you know all the basics and build on that, you may want to consider a more textbook like approach.
My hope is that I have provided some insight into one path towards learning programming. Keep in mind that you don't have to follow every step to get to the same result. Some of the steps will work for you, and others will not. The most important thing to remember is you need to do what works best for you.
An introduction to Kattni and kattni.com