The Best Ways to Teach Yourself to Code
If you want to learn how to code, taking your first steps into this huge universe might seem like a daunting, if not intimidating task. Here’s the big secret: There are plenty of free (and inexpensive) resources you can use to give yourself all the help you need, teach yourself new techniques, and make this learning process fun and exciting—as exciting as coding can get, at least.
Whether you’re an adult looking to transition into the tech industry, a student looking to learn the latest language, or a hobbyist who just wants to understand how software and services work, all you need is a computer and internet access to start your programming journey. But before you take a flying leap into The Matrix, here are our best tips and resources to set you off on the right foot.
Ask yourself: Why do you want to learn how to code?
Take a few minutes (or a day) to think about the reasons—the real reasons—why you want to learn a programming language. Be honest with yourself. Are you trying to learn the barest minimum to score a promotion? Are you looking to make a big career change? Do you want to create the next greatest app? Thrill your roommates by programming your various smart devices to do something awesome?
Your answer can help determine which programming language(s) you should master, as well as what sort of commitment (in time and money) your goal may require. For example, if your dream is to create the next great operating system or a killer alternative to PhotoShop , you would benefit from a formal computer science education that teaches you C++, as well as more complex topics like data structure, algorithms and memory allocation.
On the other hand, if you’re a mid-career professional looking to transition into a tech career, a short-term coding bootcamp might make more sense than going into debt for a second degree. If all you want to do is build websites or push your Raspberry Pi to its limits, a combination of interactive tutorials and free online courses might be enough to get you going.
Choose the right programming language
Once you figure out why you want to code, you can more easily pinpoint which programming language you should tackle. While there is no single “best” programming language to learn, some languages are more user-friendly than others. HTML and CSS are considered the easiest entry points into the coding world, but they are only really useful for developing basic websites.
Above all else, just get started learning something. Once you become comfortable with one programming language, you’ll be able to pick up the next one that much faster—like learning a new musical instrument or foreign language.
Try out some online courses
If you want more control over your learning schedule (or don’t want to go at it alone), an online coding course might be a better option than an in-person coding bootcamp. However, there are many different online classes that teach the same programming languages, and it can be hard to figure out which one is truly worth your time and money.
If you don’t mind practicing solo, check out The Odin Project, a free option that pulls together some of the best open-source content for turning a coding newbie into a programmer.
Want more one-on-one coaching and career prep without doing a full-time bootcamp? Try signing up for the subscription-model certification courses from Udacity or Treehouse, where you have the opportunity to ask a tutor for help instead of suffering your coding mistakes or questions alone. You can’t do much better than the $19 coding classes from Udemy (even less, when there’s a sale)—even full-time bootcamp and computer science students sign up for these classes to supplement their learning.
Focus on learning computational thinking
Instead of hyper-focusing on learning a specific programming language, you can also learn to problem solve in a way that a computer will understand. In other words, improve your skills at concepts like pattern recognition, algorithms, and abstractions. There’s also lingo, like loops, which are bound to pop up in any language you use. The better you understand these principles, the easier it will be to learn the next language (and design better products or projects as a result).
Thanks to the internet, you don’t have to enroll in a four-year college program to learn the fundamentals of computer science; a number of college-level classes are available online for free (or a nominal fee).
I can’t recommend Harvard’s CS50x Introduction to Computer Science enough. You can audit the course for free via edX and earn a certificate by completing all the assignments, or you can go at your own pace and watch all the lectures posted on Youtube. You can build your own DIY college-level computer science program with this selection of fifteen online courses (many of which are also listed in our Lifehacker U series).
Get a book
The best way to learn to code may involve you getting up-close-and-personal with some dead trees—a real book that you can follow along from beginning to end. In a perfect world, this will give you a more comprehensive introduction to coding than jumping around from topic to topic on a website.
You can probably find an e-book for any language or framework you’re trying to learn on GitHub, but many web developers swear by Jon Duckett’s colorful series on everything from front- to back-end web development.
As a self-taught programmer, you might also benefit from books that offer broader advice on the profession. You’ll improve your thinking and habits, traits you can apply to any language you decide to learn. Steve McConnell’s 900-page Code Complete: A Practical Handbook of Software Construction (2nd Edition) is considered the definitive guide for best practices, with data-backed advice on everything from project design to debugging code.
A corollary to that behemoth is Clean Code: A Handbook of Agile Software Craftsmanship by “Uncle Bob” Robert Martin. Martin believes code should be efficiently written for easy testing and scalability, making this a must-read for many modern dev teams.
Since programming is really about problem solving, you’ll appreciate the thought process and “back of the envelope” solutions that Jon Bentley shares in Programming Pearls (2nd Edition). Every chapter ends with a number challenges that are often used in technical job interviews, so make this book part of your job prep.
Check out some interactive tutorials or coding games
Let’s face it: reading lines of code on a screen or in a book can look like gibberish. When you see an example in action, that abstract concept suddenly makes perfect sense. That’s the beauty of interactive coding tutorials you can find around the web.
For example, FreeCodeCamp not only breaks down coding concepts into small chunks within your web browser, it also pairs each concept with a relevant exercise that you have to solve before moving onto the next topic. This way, you can’t just skip ahead to the fun stuff; the site really forces you to debug your code as you learn.
Want a more complex game development tutorial that you can put on your resume? CodinGame might be more age-appropriate if you don’t feel like punching blocks all day long.
Try a kid’s toy
Who says adults can’t learn from the same STEAM/STEM toys and video games that get kids hooked on coding? After all, these products are designed to teach coding logic and syntax without boring easily distracted children, so even adult coders might be able to find them fun and educational.
If you want to better understand the relationship between hardware and software, then you’d enjoy the Piper Computer Kit 2, which has you building a Raspberry Pi-powered computer. Using this DIY laptop, you can learn to code through its custom Minecraft Story Mode challenges, use the drag-and-drop Blockly language to learn physical computing, or just pick up some basic Python from the pre-installed lessons.
Teach your favorite devices (and assistants) new tricks
Do you have a smarthome device like the Amazon Echo? You can put your coding skills to the test by creating customized mini-programs to get more functionality out of your devices’ digital assistants. Amazon’s Alexa may already know many basic voice-command “skills,” like reading the latest news headlines, but you can teach her more complicated tasks by coding in Node.js, Java, Python, C#, or Go. (Or, if you want to start with something easier, try the simpler Alexa skill blueprints site.)
It’s possible that your interest in coding is more limited—you might just want to learn enough Python to make your Raspberry Pi do cool projects, for example. If so, you can adopt a DIY approach to learning by checking out the many projects others share on its website.
By recreating existing projects, you’ll learn more about the inner workings of your highly customizable device. You might even find yourself inspired to create new ways to use your mini-computer and delve further into the world of code. (You can even enroll in UC Irvine’s The Raspberry Pi Platform and Python Programming for the Raspberry Pi Platform class through Coursera, if you want a little help getting started.)
Watch videos about coding
Sometimes, it’s just easier to watch someone show you how it’s done. You can find all kinds of educational videos about nearly any coding-related topic nowadays: ex-Googlers sharing solutions on coding interviews, YouTubers livestreaming their coding marathons, and even programming veterans showing you how to troubleshoot a specific error in any language you want.
I recommend checking out CS Dojo, TheNetNinja, and Harvard’s CS50 YouTube channel. If you don’t have time to search for a perfect coding video or channel, you can also check out LinkedIn Learning’s vast video library for vetted and professional-looking tutorials. While the service’s $30/month subscription fee is nothing to sneeze at, you can binge-watch an unlimited amount of content and topics—making LinkedIn Learning a better deal than other on-demand online classes that come with annoying restrictions.
Practice with personal projects
No matter how many certificates and coding workshops you complete, or how many programming languages you learn, the proof of your coding skills will be in your programming project. While your personal project doesn’t have to be as ambitious as creating the next Google Maps, it should be something you’d want to work on 24/7 to constantly improve and expand its scope.
Start small, but think big. Your project should involve skills you currently have in your toolbox, but you should also have a plan for future features and skills you’d need to turn that vision into reality. Without applying your coding skills in a few projects, you wouldn’t even be considered for professional coding gigs—so start planning and practicing. (Our advice? Use your coding chops to build an amazing setup for game night.)
Celebrate Small Victories
Coding is all in the details, which is why you need to “celebrate small victories,” as one of our programming professors put it. It takes practice to make each element work on its own, as well as constant testing to ensure each line of code will work with all the rest—without errors. If you don’t do seemingly minor things right like closing a HTML tag, you’d be stuck debugging a simple syntax error rather than writing more impressive and complex code.
You need to be patient with yourself; don’t expect to code the next Fortnite after just a few months of study or a few bootcamps. Coding an error-free wedding RSVP form on a website, or making a simple-yet-correct number prediction game, is already a significant achievement for a beginner. If you get stuck, don’t give up. You should absolutely look for help everywhere you can find it, but also know when to take a break to avoid burnout. And then try, try again.
Google your error messages
This is our best piece of coding advice: If you can’t figure out why your code is broken, you can always look for solutions online. You’re probably not the first person to make your mistake, after all, and someone on the internet has surely already found a solution to your issue. Just “copy and paste” your error message into Google (or your preferred search engine), add a pair of quotation marks around the entire phrase so that you’re not just searching for keywords, then hit “Enter.” Hopefully, this little trick will lead you to the correct answer.
If you’re still having issues, you can always post your question on developers’ forums like Stack Overflow, Reddit’s programming subreddit, or GitHub. It never hurts to phone a friend—or internet stranger.
Hack someone else’s code
When you reverse-engineer someone else’s code, testing each line to see how it works, you get a better understanding of the big picture. Thanks to the tons and tons of open-source code that’s out there, you can learn just about anything by examining someone else’s (flawless) work. Just remember to share your code back with the community if inspiration strikes and you improve a part of the program you were fiddling with.
Get a mentor (or teach someone else)
The programming community is full of people who are willing to help the next generation of programmers. GitHub, the online hangout for developers who use Git to manage their coding projects, is designed for online collaboration. Not only do developers host and share their projects with their peers, they also provide code feedback and general advice to the community.
You might be able to find some helpful online mentors through GitHub, or meet other veteran developers at a local coding Meetup event or hackathon. Once you gain some experience with programming, you might be able to answer other peoples’ questions, or even teach what you’ve learned to newbies—a great test to see if you really know your stuff.
Attend a coding bootcamp
Coding bootcamps can be controversial: They’ll give you a quick introduction and experience to lots of skills, but they might not be your golden ticket to a brand-new Google job.
If you want to go pro and become a full-time developer, an intensive and in-person coding bootcamp might help you out, particularly if you learn best in a structured environment with real people to motivate you. However, these types of bootcamps are often the most expensive and time-intensive to attend: You’re looking at upwards of $15,000 for just the tuition, plus living expenses for a few months until you graduate.