How To Code

Top 10 Ways to Teach Yourself to Code

Programming is one of the most valuable skills you can pick up in these modern times, whether for career prospects or to stretch your brain and create something awesome. If you're just getting started on your coding journey, here are ten tips and resources to set you off on the right foot.

10. Figure Out Why You Want to Learn to Code

The direction you go in will depend in large part on why you want to learn to code in the first place and how much time you have to devote to learning. If you want to be a professional programmer, signing up college courses might be your best bet. (Google has a list of suggested skills and courses for would-be software engineers.) If you want to build websites or games for fun (and possibly profit) in your spare time, interactive tutorials might be better. Bloc has a comparison of course options based on workload, cost, and reason you're picking up programming. And if you're still deciding on a tech career, Switch will recommend one based on your interests.

9. Choose the Right Language

There's no one "best" programming language, and once you've learned one, it's fairly easy to pick up another, so don't get hung too up on choosing your first language. That said, some languages are more beginner-friendly than others. The language you choose to start with might depend, again, on your purpose. (For example, if you want to write an iOS app, you'll need to learn Swift.) There's a case for starting with C if you're serious about programming, although higher-level languages, like Python, are easier to jump into right away. Here's an infographic comparing a few popular programming languages.

8. Start Small (and Be Patient)

No matter which language or learning method you choose, you should start at the very beginning (a very good place to start). When David Sinsky taught himself to code in eight weeks, for example, he spent one weekend getting an introductory grasp of Python and one weekend getting an introductory understanding of Django—going through the tutorial, deleting all of the tutorial code, and working through the tutorial again from scratch. Start with the basics and be patient with yourself as you progress. To take your first coding project from start to finish, break down the project into simple steps. And if one method of learning isn't working for you (e.g., books), try another method before giving up.

7. Try a Kids App

Even toddlers are learning to code these days. That's actually a great thing for all of us. Although many of the programs designed to teach kids to code are very simplistic, many of them, like Scratch, are suitable for all ages. It doesn't matter how old you are; even kids' animation apps can get you started with the basics of programming (edX has a new course on Programming in Scratch, by the way).

6. Use Free Online Training Sites

Free online training sites like Codecademy and other Hour of Code participants can help you write your first computer program. Tutorials from KhanAcademy, Codecademy,, and many other organizations will introduce you to the basics of programming—all while creating a new game, site, or other project. Find the resources you need according to the language you're learning with Bento. These are good starting points, but you'll need to take the initiative to further or continue your learning after these introductions.

5. Take a Coding Course

Online computer science courses offer a bit more of rounded educational experience compared to online training sites focusing on one language. These courses are designed to teach you fundamental skills over several months in college-level classes. I can't personally recommend Harvard's CS50 (which you can take for free) enough, but there are many others you can take (many listed on our Lifehacker U series). You can even build a college-level computer science education with this selection of fifteen online courses.

4. Grab Some Free Programming Books

When you get stuck on a problem or just need to look something up, reference books come in very handy. There's a huge collection of over 500 free programming books posted on GitHub, and another collection of Ebooks covering 24 programming languages.

3. Play Coding Games

Often the best way to learn is through games. While plenty of coding tutorials have you building simple or complex games yourself, a couple of teaching sites are literally games: Code Combat and CodinGame are two you might have fun with.

2. Get a Mentor (or Teach Someone Else)

The programming community is full of people who are willing to help the next generation of programmers. Hack.pledge() is one site that will connect you to a mentor, or you can sign up to mentor someone else. Even just planning to teach what you've learned can help you retain the information better.

1. 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 tons of open source code, you can learn just about anything—and keep learning through the incremental-hacking cycle. Just remember to share your code back with the community if you improve on a program.

Are You Know?
Apple Delivers a New iPad With Less Hype
Is it the end of The Pirate Bay? Studios Look To Offer Movies Early In Home For $30
iOS 10.3 will probably make your iPhone feel faster

Programmer 101: Teach Yourself How to Code

You've always wanted to learn how to build software yourself—or just whip up an occasional script—but never knew where to start. Luckily, the web is full of free resources that can turn you into a programmer in no time.

Since the invention of the internet, programmers have been using it to discuss software development techniques, publish tutorials, and share code samples for others to learn from and use online. If you're curious about how to become a programmer, you can get off to a running start using tons of great free web-based tutorials and resources.

First Things First: Don't Get Hung Up on Choosing a Language

A common pitfall for beginners is getting stuck figuring out which programming language is best to learn first. There are a lot of opinions out there, but there's no one "best" language. Here's the thing: In the end, language doesn't matter THAT much. Understanding data and control structures and design patterns does matter very much. Every language—even a simple scripting language—will have elements that you'll use in other languages as well and will help you learn. In classes I took to get my degree in Computer Science, I programmed in Pascal, Assembly, and C—languages I never actually got paid to program in professionally. I taught myself every language I've used in my career, reusing concepts I already knew, and referring to documentation and books to learn its syntax. So, don't get hung up on what language to learn first. Pick the kind of development you want to do, and just get started using one that works.

There are several different kinds of software development you can do for various platforms, from the web to your desktop to your smartphone to a command line. In this article, we'll outline some of our favorite starter tutorials and resources for teaching yourself how to program for each major platform. We're going to assume you're a savvy user, but a newb when it comes to wrangling code snippets, so we'll keep things at the beginner level. Even just following through a beginner programming tutorial, you'll be happy to see how far you can get.

Desktop Scripting

The easiest way to try your hand at programming for your Windows or Mac desktop is to start with a scripting or macro program like AutoHotkey (for Windows) or Automator (for Mac). Right now hardcore coders throughout the Lifehacker readership are yelling at their monitors, saying that AHK or AppleScript are not "real" programming. That may be true—technically these types of tools just do high-level scripting. But for those new to programming who just want to get their feet wet, automating actions on their desktop, these free tools are a fantastic way to start—and you'd be surprised at how much you can do with them.

For example, Adam developed the standalone Windows application we all know and love, Texter, using AutoHotkey, so this scripting language is capable of far more than just small-scale automation projects. To get started with AutoHotkey, check out Adam's tutorial on how to turn any action into a keyboard shortcut using AutoHotkey. (Then, check out the source code for Texter to see the innards of a full-fledged AHK-based Windows application.)

Web Development

Instead of being bound to specific programming languages and the look and feel of a particular operating system, you can put your killer application in the browser and run it in the cloud, as a webapp. Welcome to the wonderful world of web development.

HTML and CSS: The first thing you need to know to build any web site is HTML (the page markup that makes up web pages) and CSS (the style information that makes that markup look pretty). HTML and CSS are not true programming languages—they're just page structure and style information. However, you should be able to author simple HTML and CSS by hand before you begin building web applications, because a web page is the frontend to every webapp. This HTML tutorial is a good place to start.

JavaScript: Now that you can lay out a static web page with HTML and CSS, things get fun—because it's time to learn JavaScript. JavaScript is the programming language of the web browser, the magic that makes dynamic in-page effects go. JavaScript is also the stuff of bookmarklets, Greasemonkey user scripts, and Ajax, so it's the key to making all sorts of web goodies. Start learning JavaScript here.

Server-side scripting: Once you're good at making things happen inside a web page, you're going to need to put some dynamic server action behind it—and for that, you'll need to move into a server-side scripting language, like PHP, Python, Perl, or Ruby. For example, to make a web-based contact form that sends an email somewhere based on what a user entered, a server-side script is required. Scripting languages like PHP can talk to a database on your web server as well, so if you want to make a site where users can log in and store information, that's the way to go. Excellent web development site Webmonkey is full of tutorials for various web programming languages. See their PHP Tutorial for Beginners. When you're ready, check out how to use PHP to talk to a database in WebMonkey's PHP and MySQL tutorial. PHP's online documentation and function reference is the best on the web. Each entry (like this one on the strlen function) includes user comments at the bottom which are often as helpful as the documentation itself. (I happen to be partial to PHP, but there are plenty of other server-side scripting languages you might decide to go with instead.)

Web frameworks: Over the years, web developers have had to solve and resolve the same problems and rewrite similar code to build dynamic web sites. To avoid making everyone reinvent the wheel for every new web development project, some programmers have come up with development frameworks that do some repetitive work for you. The popular Ruby on Rails framework, for example, takes the Ruby programming language and offers a web-specific structure for getting common web application tasks done. In fact, Adam used Rails to build his first serious (and impressive!) web application, Here's his take on how to build a web site from scratch with no experience. Other popular web development frameworks include CakePHP (for PHP programmers), Django (for Python programmers), and jQuery (for JavaScript).

Web APIs: An API (Application programming interface) is a programmatic way for different pieces of software to talk to one another. For example, if you want to put a dynamic map on your web site, you want to use a Google Map instead of building your own custom map. The Google Maps API makes it easy to programmatically include a map in a page with JavaScript. Almost every modern web service you know and love has an API that lets you include data and widgets from it in your application, like Twitter, Facebook, Google Docs, Google Maps, and the list goes on. Integrating other webapps into your web application via API's is the final frontier of rich web development. Every good, major web service API offers thorough documentation and some sort of quick start guide to try it out (here's Twitter's, for example). Go crazy.

Command Line Scripting

If you want to write a program that takes textual or file input and outputs something useful, the command line is the right place to do it. While the command line isn't as sexy or good-looking as a webapp or desktop app, for rapid development of quick scripts that automate processes, you can't beat it.

Several scripting languages that work on a Linux-based web server also work at the command line, like Perl, Python, and PHP—so learning one of those baddies makes you conversant in two contexts. My path never took me too far down the Perl road, but I taught myself Python using the excellent and free online book, Dive into Python.

If becoming a Unix ninja is one of your programmer goals, you absolutely must get good at shell scripting with bash. Bash is the command line scripting language of a *nix environment, and it can do everything from help you set up automated backups of your database and files to building out a full-fledged application with user interaction. Without any experience writing bash scripts beyond a dozen lines, I wound up developing a full-on personal to-do list manager in bash, Todo.txt CLI.


Nowadays, modern webapps and browsers are extensible with with bits of software that bolt onto them and add features. Add-on development is gaining in popularity as more developers look at existing software, like Firefox or WordPress, and think "But if only it could do THIS..."

You can do a whole lot in any web browser with just a mastery of HTML, JavaScript, and CSS. Bookmarklets, Greasemonkey user scripts, and Stylish user styles are created with the same bits of code that make regular web pages, so they're worth learning even if you just want to tweak an existing site with a small snippet of code.

More advanced browser add-ons, like Firefox extensions, let you do more. Developing Firefox extensions, for example, requires that you're conversant in JavaScript and XML (markup that's similar to HTML, but way more strict in format). Back in 2007 I ran down how to build a Firefox extension, a skill I picked up after I stumbled upon a free tutorial.

Many free and well-loved web applications offer an extension framework as well, like WordPress and MediaWiki. Both of those apps are written in PHP, so comfort with PHP is a prerequisite for getting started. Here's how to write a plug-in for WordPress. Developers who want to ride the cutting edge of Google Wave can get started writing gadgets and bots in HTML, JavaScript, Java, and Python. I wrote my first Wave bot following this quick start tutorial in one afternoon.

Web Development for the Desktop

The best part about getting started programming in one context is when you can take those skills and apply them elsewhere. Learning web development first is a great way to start because now there are ways to put those skills to work on desktop applications, too. For example, Adobe AIR is a cross-platform run-time environment that lets you build your app once and release it to run on the desktop for every operating system AIR runs on. AIR apps are written in HTML, Flash, or Flex, so it lets you apply your web development skills in a desktop context. AIR is a great option for deploying desktop apps like one of our top 10 apps worth installing Adobe AIR for.

Mobile App Development

Mobile applications like the ones you run on your iPhone or Android smartphone are all the rage right now, so you may have dreams of striking it rich in the iTunes App Store with the next killer app. However, for the new coder, diving headfirst into mobile development can be a rough learning curve, since it requires comfort with advanced programming languages like Java and Objective C. However, it's worth checking out what iPhone and Android development looks like. Check out this simple iPhone application development example to get a taste of what iPhone developers do. Android apps are written in Java, and here's a friendly video tutorial of what building a "Hello Android" application workflow looks like.

Patience, Elbow Grease, Trial and Error

Good coders are a special breed of persistent problem-solvers who are addicted to the small victories that come along a long path of trial and error. Learning how to program is very rewarding, but it can also be a frustrating and solitary experience. If you can, get a buddy to work with you along the way. Getting really good at programming, like anything else, is a matter of sticking with it, trying things out, and getting experience as you go.

This article is just one self-taught programmer's top-of-mind recommendations for beginners. Experienced programmers: What did I miss? No matter your skill level, add your thoughts and recommendations for beginners to the comments.

Please don’t learn to code

There’s an idea that’s been gaining ground in the tech community lately: Everyone should learn to code. But here’s the problem with that idea: Coding is not the new literacy.

If you regularly pay attention to the cultural shenanigans of Silicon Valley, you’ve no doubt heard of the “Learn to Code” movement. Politicians, nonprofit organizations like and even former Mayor Michael Bloomberg of New York City have evangelized what they view as a necessary skill for tomorrow’s workforce.

There may be some truth to that, especially since the United States’ need for engineers shows no sign of slowing down.

But the picture is more complicated.

We live in an ultra-competitive world, with people turning to all sorts of methods to make ends meet. Selling coding as a ticket to economic salvation for the masses is dishonest.

Take coding bootcamps. Since the mainstream learned of the success of Silicon Valley software engineers, everyone wants to own a startup or become an engineer. HBO’s Silicon Valley paints a picture of late twenty-somethings spending their nights coding and smoking weed, all whilst making millions of dollars. The American public is amazed by figures like Elon Musk and Mark Zuckerberg, who make millions seemingly overnight. Coding fever has even reached the steps of the White House, with President Obama pushing for legislation to include computer science in every public-school curriculum.

Inexplicably, it is not just bootcamps and politicians encouraging people to learn to code.

Individuals are actively encouraged to do so from all sides of society, from Hollywood to current tech luminaries. Despite this growing buzz, I view bootcamps with intense skepticism. While our culture tends to make Silicon Valley sexy, and glossy bootcamp brochures promise well-paying jobs, the truth is that many of these institutions are not accredited, do not post job statistics and do a poor job of ensuring their students’ post-bootcamp success. While many coding bootcamps are legitimate and care for their pupils, an even greater number are run by modern snake-oil salespeople tapping into the average American’s desperation.

Don’t get me wrong; I do believe that engineering and programming are important skills. But only in the right context, and only for the type of person willing to put in the necessary blood, sweat and tears to succeed. The same could be said of many other skills. I would no more urge everyone to learn to program than I would urge everyone to learn to plumb.

Focusing on coding inflates the importance of finding the “right” method to solve a problem rather than the importance of understanding the problem.

Before we start working on a solution to a coding problem we must decide what the problem is — and if it’s truly a problem. If we let ourselves become fixated on how to solve a problem via code, regardless of if it is a programming problem or not, and lose sight of why, we gain nothing.

I have a close friend who is a former Association for Computing Machinery International Collegiate Programming Contest champion from Stanford. The greatest thing he taught me about his ACM championship days was the importance of understanding what problem you’re trying to solve.

You must ask yourself, “Do you even have one?” and “Can you apply the Feynman principle and explain it in a way that others can understand you?”

This friend told me that even in the elite schools, students read the prompt to the coding problem only once then immediately code.

The year my friend won the championship he learned something: even those from elite schools dove headfirst into complicated problems, with code as their only weapon.

Meanwhile, my friend wrote his code only after thoroughly understanding the problem. He used almost all the allotted time to think about the problem. He did not write code until minutes before the deadline.

He became a champion.

He knew that banging out code would not solve the problem, but cool, collected problem solving would.

An excessive focus on coding ignores the current plight of existing developers.

Technology changes at a rapid pace in this industry.

Just a few years ago I was using Objective-C; now I code almost entirely in Swift. There are iOS developers applying for jobs right now who have never written a line of Objective-C. Swift is easier to learn, safer, uses modern development paradigms and is elegant in a way that Objective-C never was. The fact that new developers will never deal with Objective-C’s deficiencies is great, but it ignores the reality of the profession.

Developers are expected to learn fast, with little guidance and little more incentive than the faint rattling of the pink-slip guillotine. One could argue that this is simply one of the costs of the trade. But if current developers are frustrated or falling behind — and there is evidence that shows this is the case — why encourage individuals to enter such an uncertain realm?

What happens to the person who spent night and day studying Objective-C only to be horrified by the Swift announcement at WWDC 2014? Do they keep coding in what is quickly becoming the language of lesser choice, or do they start again? If you’re a young twenty-something, this may pose little difficulty, but if you’re taking care of a family — with bills to pay and mouths to feed — the task becomes Herculean.

People in these situations confront all of this without a solid grasp of actual programming or engineering.

The line between learning to code and getting paid to program as a profession is not an easy line to cross.


It took me more than a year of self-taught study before I got a freelance gig. Even then, the pay was poor. There were countless times I was refused even an interview because I didn’t have a computer science degree.

There were times when I could not afford a place to stay and had to rely on the kindness of friends to keep me going. There were many nights when I wanted to give up. But I found the strength to keep going.

It was — and is — persistence that allows me to stay in this field.

The truth is, it simply isn’t easy to slide into a development gig, even if it’s an apprenticeship. You need connections, people to vouch for you, a GitHub account maintained over time and more. Despite advances in equal opportunity, if you’re an underrepresented minority, you’re going to have to be twice as good as everyone else. And that’s simply to demonstrate competence.

The gatekeepers are anywhere. They are Ivy League graduates who believe asking questions like, “How do you invert a binary tree?” is the best way to gauge someone’s technical ability. They are the whiteboard test-obsessed project managers (confession: I own multiple whiteboards) and the clueless HR managers who list requirements like, “5 years of Swift Programming Language Experience needed” in job postings (hint: Swift release = 2014). These people, for better or for worse, stand between you and a decent job.

As far as I know, there’s no other way to get past these people than to play their game, even if it is unfair.

Final thoughts

If becoming an engineer is what you want, don’t let me — or anyone, for that matter — get in the way of your goal. And don’t let traditional confinements like the educational system slow you down. There are no correct or incorrect ways to go about achieving your goals.

But don’t lose sight of reality while being charmed by our culture’s Silicon Valley romance. This field is not a get-out-of-debt-free card. You have to take the time to build your understanding of the field. You have to become comfortable with the fact that you are a problem-solver and not simply a “fill-in-framework-here” developer. You also must get used to the idea that at any moment you might need to learn a new framework or language, and that you will have to fight for a job if you don’t have formalized credentials.

Software engineering is a lucrative field, but the transformation from “coder” to “engineer” is challenging.

If you stick to it, you can not only change your life, but change your entire way of thinking.

0 Response to "How To Code"