How to Start Learning to Code

This is not a comprehensive guide, or the only way to start, but it's how I got started and it might be relevant for you.



Get a feel for basics



To get a quick feel for programming, you can get started on a free website and try some of the exercises. This is the site where I first started learning how to code: www.codecademy.com



Here are some of the tracks I'd recommend on Codeacademy:



  1. HTML/CSS - This is the easiest, it lays the groundwork of making a website. HTML is the layout, CSS is the style on a page. It's immediately rewarding because you can see colors and shapes change.

  2. Python or Javascript - For a first programming language, I'd recommend starting with Python, since it's known to be easy to learn, and great for science and math. If the HTML/CSS course was more interesting though, Javascript is a good complement since it's used to make websites interactive. You usually learn it along with HTML and CSS for web development.

  3. Bash/shell - This course teaches how to use the command line, which is how you do things from the terminal of a computer. It's essential to learn this to start running your own programs on your computer, but it's also possible to mess things up in the terminal if you don't know what you're doing -- with great power comes great responsibility. If everything above has been interesting and you get to the point where you want to move out of online tutorials and run your own programs, you should set up a programming environment on your computer and start learning to do everything from the terminal. Just be sure to learn the 2 or 3 lethal commands that you should never use.



I also took some lynda.com courses in the beginning. These days there are probably better free online courses.



Set up a programming environment



Download a text editor to write your programs in, and get comfortable navigating from the terminal. Download the programming language you're starting with if your computer doesn't have it pre-installed. Write a simple program, save it with the right extension, and try running it from the terminal. Example: `hello-world.py`



def sayHello():
  print "Hello World"

sayHello()



Output: `Hello World`



Use version control



You'll need it. Version control protects you if you mess up, and lets you collaborate with other programmers. A version control system keeps tracks of changes that you make, so that you can go back to an earlier state, work on multiple implementations at once, or merge changes worked on by multiple people at once. I'd recommend using git and Github, since there are so many users on there, and they make it easy to collaborate on code with others.



  1. Install git

  2. Create an account on Github

  3. Create a new repo, and follow the instructions to push the code on your computer onto Github.

  4. Use the search bar to find code for something you're interested in on Github. Clone the repo, and start reading the code. Try to run it. Try to modify it. A fun thing to do is to try to make a small change in a complex program someone else wrote.



Improve your skills



  1. Read code. In the beginning, it's as important to read code as it is to write code. You want to be able to look at a program and quickly get a sense for what it's doing. Find an open source project that does something you like and figure out how it works. Find a programmer you admire and read through their code.

  2. Don't try to read books on programming from start to finish. This was my default approach when I started, and it was not effective. Maybe it's possible to learn this way, but it's much harder. What's more effective is just diving in and writing code before you really know what you're doing. There's an infinite number of things you could potentially learn, so you have to figure out what you really need to learn in order to be productive. Try building something, and read the docs when you get stuck.

  3. Copy until you can create. Take a functional program someone else wrote and modify it so it does something different. Copy a better programmer's coding style. Look at a project and see if you can re-build it. Find a simple program in a language you don't know and copy it into the language you're learning.

  4. Stackoverflow is your friend.



Find a community



Sitting in front of a computer all day doesn't have to be isolating. Find people who are on the same learning journey as you, or who are farther along and willing to help.



When I first started learning to code, the web developer at the nonprofit I worked at was my only reference point. Knowing I had someone to turn to if I bricked my computer somehow (I'd decided Real Programmers use Linux and partitioned my hard drive) was reassuring.



Resources for Kids



This is the best online resource I've heard of for kids learning how to code: https://code.org/learn



There are hour-long tutorials on coding topics for every age group, with interactive exercises, and they try to make them fun. It should be a great starting point.



To reply you need to sign in.