Skip to main content


Programmers of Reddit, what is the best way to learn to code?


  1. 1) You write some code (the easy bit) 2) Someone uses it to do their job. (after unit testing, UAT, etc etc) 3) They come screaming to you that it's month-end, your code doesn't work, millions of dollars are at stake and the account has to be closed at the end of this afternoon. *That*'s how you learn to code.
    — Hackrid

  2. Honestly, learning to code is easy. Learning how to write efficient code is harder. Learning how to write maintainable code is hardest. I would argue the most important thing to do is work with other people as often as you can. I arrived at undergrad already a really theoretically good programmer who knew every arcane detail of 2 or 3 languages and was proficient in half a dozen. I could mathematically optimize to hell and back. But do you know what? I was an absolutely shitty software engineer. I'd spent years writing code that no one ever looked at, let alone worked with, and consequently picked up a bunch of bad habits without knowing it. So first things first, learn a programming language. It doesn't matter how you do that; there are a half a dozen ways. I started with C. I'd recommend either C or Java because the ambiguous type semantics in python can make it really easy to produce code that will work even if you don't understand why it works. Ideally pick one that has a good styleguide available in the wild. I try to follow the [Google Styleguides](https://google.github.io/styleguide/) for my personal projects. You won't understand styleguides as comprehensive as Google's just getting started; you need to actually know the language first. But once you do know the language enough to not get lost, read the styleguide you picked and follow it religiously. Later you'll learn enough to argue for that a willful violation of the styleguide is justified, but you're a long way from there. Next, read a book on Design Patterns. Head First Design Patterns is a good way to learn design patterns, or the "Gang of Four" book on Design Patterns is a bit denser and makes a better reference to come back to. Note the singleton design pattern, however: it should be avoided if at all possible. When you're starting out, it's always possible. After that, start on a fairly big personal project. Something that interests you. While you're at it, check out [Misko Hevery's guide to writing testable code](http://misko.hevery.com/code-reviewers-guide/) and [Joshua Bloch's API Design by Bumper Sticker](https://www.infoq.com/articles/API-Design-Joshua-Bloch). Submit your code to code review forums. Now: does your project run fast enough? It's always good to have a vague awareness of complexity, but this is the first time you should actually think about it, lest you risk premature optimization. It's time to start taking a look at algorithms. Start with a book on Discrete Mathematics, if you haven't read it before this point. Next comes analysis of algorithms. Then it's basically a matter of what field you're in, but you'll want to look at a general textbook on algorithms. [Carnegie Mellon's textbook is available for free](http://www.parallel-algorithms-book.com/). Don't discount mathematics, either. Calculus has its place in machine learning and physics. Number theory is incredibly useful to cryptography. Graph theory is essential to path finding. Etc.
    — bxtk

  3. Get a book on python or Java that has example problems/test questions. Do 2 easy and 2 medium problems for as many days straight as you can. If you get stuck, don't just Google the solution, instead read the hints in the book for clues. If you spend 2 hours on a single problem with no progress, then you can use websites like stack overflow for help. PM me if you need more help.
    — thedoorholder



  4. The best way is to try to automate tasks in your workplace that you're too lazy to do manually :) Really, this is how I arrived at a 75k+ salary. Edit: also, never stop untill you've solved the problem. Edit 2: Google is your friend.
    — LUCTOR_ET_EMERGO

  5. Decide on something you'd like to do. Anything softwareish at all. Then imagine the simplest version possible of that. Pick a language, doesn't really matter which, and make that simplest thing. Keep making simple things. Iterate on the things you've made and make them less stupid simple. E.g: > I wanna make the next Skyrim! Great, you want to make a game. What's the simplest game you can think of? > tic tac toe? Great, go pick up python and make tic tac toe for 2 human players, in the terminal. > fuck that was hard Yes, coding is hard. It's about solving the hard problems. The easy problems, we code programs that solve those automatically. Now iterate on your tic tac toe. Perhaps you could: * make a simple AI * add a GUI * make the board arbitrary size * allow players to save the game and return later * turn one of the X-es into a D for dragonboy, the protagonist of your future masterpiece Skiram, and make so the player can move it across the board? Good luck!
    — evilcandybag

  6. A few thoughts: 1. don’t learn just one language. Programming is about problem solving, not python vs Java vs C A good programmer can pick up a new language quickly if they learn the problem solving skills. 2. Pick a small problem and then solve it several time in different ways. There are many way to solve any problem, Having more tools in your tools box is good. 3. Read other people’s code. It’s good to see how other do things. 4. Try not to copy paste code you don’t understand. It can get too easy to make a programme that works but you don’t really know how it works. 5. Once you have some programming skills go down to a lower layer. Each abstraction layer hides how the computer really works. The lower in the stack you get the more you really understand. Start with scripting like python or ruby. Move down to C or C++ Move down to assembly if you want to.
    — Robsonde