How to learn programming? This is probably the key question everyone asks himself at the beginning of his programming career. No matter what language you start with - programming has so many aspects and facets, it's extremely hard to figure out how to start.
Recently I came across this question again on Reddit. But instead of answering in the comments I've decided to write a blog post about how I've learned programming years ago. It's actually a summary of do's and don'ts for beginners - the lessons I've learned back in 2001 when I had started with Java.
You should read the corresponding wikipedia articles for those languages which sound interesting to you to get a general view and then decide which language you want to start with. But don't stress you too much, learning the second language is much simpler than the first - so your decision is not written in stone.
Often the language decision is taken by someone else for you, e.g. if you're going to visit a programming course at school, university or even online. This is how I started to learn programming in Java at university back in 2001. We first made a quick excursion to Scheme (a Lisp-like language) before we deep-dived into Java.
The first things you probably learn in a programming 101 course is the basic syntax and semantic of the language. If you're not able to visit a programming course in real life don't bury your head in the sand. There's plenty of ways to learn the basics of programming. Sites like Code School or Khan Acadamey offer online programming courses. Some universities offer online video lectures (see Coursera). And of cause you can just buy a programming book for beginners. Go to Amazon and search for e.g. java beginners guide (make sure to read the reviews).
Don't learn solely with blog tutorials because more than often they are superficial and unsuitable for beginners. Tutorials are great for more advanced programmers but not so great for beginners.
Meanwhile you're able to write some basic code. Depending on the language you eventually know how to compile and run the code on your local machine. You also have some basic understanding how to structure the code in your language of choice. This is a good moment to start your first example project in order to gain more practice. Depending on how you learn your lector/ mentor/ book author will usually provide enough exercises for you to practice what you've learned.
Here's my most important advice to you: Avoid using StackOverflow.com to find the answers to your questions! Seriously, don't do it! StackOverflow is a great source of knowledge but it's counter-productive while in the process of learning the basics of programming. If you use StackOverflow you'll find yourself copy/pasting code snippets into your code without thinking enough about the fundamental concepts and how the code really works.
Instead you should focus solely on the documentation provided by your course or the book you read. You should also use the official language documentation. Using those documentations for solving problems teaches you crucial researching technics. Often you find yourself reading about stuff which not only solves your current problem but widens your knowledge in other parts of programming.
You have to research and find out things by yourself in order to become a great programmer. This way of learning is lengthy and tedious but it definitely pays off at the end.
Failure is good
After successfully finishing your first small programming projects you should feel quite comfortable with the basic edit - compile -run cycle of programming. You're doing fewer syntax mistakes resulting in fewer syntax errors while compiling the code. But you eventually still see semantical errors quite often. But don't be to afraid - failure is good. Every failure you encounter and every problem you solve let your knowledge grow. Even the most advanced programmers make mistakes from time to time.
Every programming language has famous errors like
NullPointerException in Java or
As I've already mentioned the only right way to learn programming is to actually write code. A lot of code! Nobody can teach programming without you constantly coding stuff and solving problems with code. You have to get your hands dirty and your keyboard smolder. It's the only way to master the craftsmanship of programming.
So the key to learning the first programming language is to constantly solve different kind of problems. And that's where StackOverflow again comes into play. I've already told you to avoid all those answers on StackOverflow. But if you just look at the questions you'll find a shear endless stream of problems to solve by your own.
All you have to do is search for a particular topic of interest but blend out the answers so you can solve those problems by your own. It doesn't matter if the questions are already answered by others. We're here to learn something new, not to gain virtual reputation on StackOverflow.
Here's a few sample search queries for java-related questions:
- java file read
- java inputstream
- java localdatetime
- java pattern matcher
- java executors
- java collections
- java stream reduce
This is how I've really learned programming back in 2004. I already had a good understanding about the syntax and basic semantic of the Java language and successfully finished a few example projects. But my knowledge about the huge Java API was mediocre. So I started to constantly solve problems other people have posted in programming forums on the internet (see this and this - since there was no StackOverflow in 2004).
Test your skills
After a couple of months you should be well on the way to understand most of the fundamental parts of the language and it's APIs. That's a good moment to determine how good you really are. In my opinion a great way to test your knowledge is by teaching others.
When I was studying computer science at university after a couple of semesters I worked as a research assistant with the responsibility to lead practicing groups for the same programming courses I've completed myself before. It was a fun experience and a great way of testing my programming knowledge because I was forced to go into deep detail of all the programming concepts in order to help the participants of my practicing groups.
An alternative way to working as a research assistant could be to start a programming blog on the internet. Writing about your experience of learning the first programming language can be both satisfying to you and interesting to other beginners who're in the same boat as you. Writing a blog post also forces you to go into deep detail and you can measure your success on the feedback others give back to you.
You've successfully learned your first programming language. You gained deep knowledge in the relevant APIs by solving a bunch of problems posted on StackOverflow. And you've proved your skills by teaching other beginners and spreading your newly gained knowledge with the world. Now you're ready for your first job as a junior software developer!
I wish you the best of luck on your journey. Hopefully my tips are as useful to you as it was to me. Feel free to send me your feedback if you have any further questions.