You have zero programming knowledge and you want to start learning to code. Where do you start?
Maybe you want to learn enough to get yourself a coding job, or you're planning to study computer science in the future and you want to try it out before you start your course. Maybe you just want to automate a few things here and there.
This post will outline a path to getting comfortable with coding. It's certainly not the only way to learn programming, it's just the advice that I would give anybody who asked me.
Learning the basics
First you'll need to pick a programming language to learn. This won't be the only language you ever learn if you pursue programming long-term, I've been coding for about 5 years and I know roughly three-and-a-half to six languages, depending on what counts as a "language", so this choice isn't forever.
If you haven't already picked something, learn Python. It's one of the easier languages to get started with, has a syntax that almost looks like natural language and you can get a lot done with it. There are also a lot of good beginner resources for learning Python.
You should follow a bare-basics course or book to get started, like Real Python's introductory course or the often-recommended Automate the Boring Stuff with Python book. There are dozens of books and courses you can choose, so just pick one and learn the basics. I've also written about some other tools that you should look into when programming (specifically on Windows).
"The basics", which I have mentioned so far, will include:
- installing Python on your computer
- running Python scripts on the "command line" (CLI)
- variables, data types, simple data structures
- control flow (if, else, for, while)
- printing output to the CLI
- reading user input from the CLI
- reading from and writing to files
It's going to feel very simple and kind of dumb. After a week of messing around you might be able to build a simple text-based calculator. That's pretty normal: your first programs will not be very impressive at all. Maybe you spent your first week just-trying-to-fucking-install-Python, which isn't that abnormal either.
Many small challenges
Once you've read a book or followed a course and gotten the basics down, you need to start setting small challenges for yourself. You can't just do tutorials forever... well you can, but you'll always be dependent on them to learn new things. You need to come up with your own problems and build your own solutions. You might start by building:
- a script that asks your name and prints it back to you
- a text-based calculator that helps you add, multiply, divide
- a script that tells you the number of days between two dates
- a script that prints out your workout for the day
The point isn't that these are particularly useful or impressive programs, it's that you set a challenge for yourself and then build a working solution. This is something you should do over and over. You will get stuck and need to search Google and check Stack Overflow, read the official Python documentation, and ask for help on /r/learnprogramming and /r/learnpython. Getting stuck, and then getting unstuck is a part of being a programmer, and tutorials that hold your hand won't teach you how to solve your own problems. Since you are doing lots of small challenges, it's OK if you need to give up and try something easier before coming back to it later.
Don't get me wrong, tutorials are great resources for learning a specific skill, but you cannot learn from them alone.
If you're having trouble inventing your own challenges, then check out Code Abbey, which has a bajillion problems to solve with a wide range of difficulties.
Once you're comfortable with the basic syntax of Python and solving simple problems, you can slowly ramp up the complexity of the problems and start playing around with third party libraries. You might eventually:
- make a script that pulls data from a webpage and prints it to a screen
- write a simple website that stores your "to-dos" in a database
- write a script that finds and deletes duplicate photos on your laptop
- learn to create webpages with HTML and CSS
- read and write data from a spreadsheet (Excel, Google Sheets)
- learn SQL to manage databases
You won't know how to solve these problems to start, which is part of the process: Googling around until you figure out how to achieve your goal. I don't actually remember very much about the coding tools and languages that I use day to day - I'm just a fucking gun at Googling things. I'm a professional Django developer (most of the time) and when I'm working on Django projects I will check the documentation at least once an hour. Developing your Google-fu and learning how to read documentation will be vital for your programming abilities.
More advanced theory
If you get comfortable with coding and want to get a head start on your studies, then you should try some more advanced online courses. Even if you aren't going to study computer science at school, there are great benefits to learning some theory.
I recommend choosing something that teaches computer science concepts, not just how to use particular tools. I think Principles of Computing is a fantastic course for dipping your toes into computer science, with engaging coursework and a focus on the practical skills that a software engineer needs. Nand2Tetris is awesome, but a little more challenging. There is an absurd number of free online computer science courses, these two aren't the only good ones, they're just the ones I have personally done and recommend.
Learn some more advanced tools and frameworks
Eventually you'll want to do something practical with your coding, and you won't want to build everything from scratch. With a solid grounding in Python and basic programming, you can branch out to learn about:
- scientific computing (NumPy, SciPy)
- data science tools (pandas, matplotlib, Jupyter notebooks)
- web development (Flask, Django)
- web server admin (Linux, SSH, SCP, apt, AWS, etc)
- databases (SQLite, Postgres, SQLAlchemy)
I recommend that you learn these tools with a small project in mind, to better motivate and guide your study.
So in summary, I recommend you:
- learn the basics of Python by following a beginner's course or book
- do lots of small self-guided coding challenges
- try some more advanced self-guided challenges and new tools
- learn some computer science theory
- learn some advanced tools and frameworks
If you have any feedback or questions email me at [email protected]