How to learn any programming language.
Get a book or tutorial that teaches the language
The process of learning any human language is almost the same as learning a programming language.
The only difference is that programming languages are designed to communicate with computers rather than humans. How can you learn a programming language and be good at solving problems with it?
1. Get a book or tutorial that teaches the language
Don't make the mistake. You don't have to choose between using written books and watching tutorial videos. Go with the one that you works best for you.
If you are just starting out, you can try out both videos and books. Overtime, you'd know which one suits your learning. You can also use both of them - I use both tutorial videos and books to learn by the way.
However, it is good practice to code-along if you are using videos to learn. It will help you get better at typing code yourself. The same concept applies if you are reading programming books. If you are a beginner, type the code in the books yourself into the editor(NO COPY AND PASTE).
2. Download a code editor or IDE(Integrated Development Environment)
A code editor or IDE(Integrated Development Environment) is where you type in your code and run it. It is more like a word processing package, but it is used to write and run your code. There are tons of code editors out there. Some are beginner-friendly, while some are not. Here's a list of code editors I recommend:
a. Visual Studio Code(VS Code) - It is a powerful cross platform code editor integrated with capabilities to make you write code faster and perform other necessary tasks you will need to do. I personally recommend this IDE. It has a lot of fun capabilities. It supports multiple languages and lets you download necessary extensions at a go. Download VS code
b. Sublime text - Sublime text like VS Code is also a lightweight cross-platform code editor with good user interface and a friendly user experience for beginners. It also supports multiple languages. Download Sublime text
c. Notepad ++ - This is also a beginner-friendly code editor. It runs only on windows OS. Download notepad++
There are tons of code editors out there. Some are not beginner-friendly. If you are just starting out, I recommended using any of these.
3. Learn the basics.
The fun thing is every programming language are alike in structure and design. This is why it is important to learn the fundamentals of programming itself. Programming has to do with solving problems. Every programming language only provides a means to do that. This implies that programming languages are alike in most aspects, only their syntax differ. Some of the basics of a programming language to learn include:
- Conditional statements.
- Input and output operations.
Every programming language operations with the above. What's the point? While going through your tutorial, make sure to understand vital concepts like loops, when to use loops, how to write elegant code, using comments in your code etc. These concepts are in every programming language. You are only setting yourself up for frustration if you don't learn and understand them.
4. Start by solving simple problems.
This will help sharpen your understanding and build your confidence. Try to put together pieces of code that does something. Examples include: *A program to perform simple arithmetic operations.
- Printing a list of numbers in a range.
- Looping through an array or list. etc
It could also be a program to solve a problem you encounter. I once a wrote a program for calculating the factors of a quadratic expression.
5. Learn to break down problems into bits
You might be tempted to skip this step, but DON'T. It will save a lot of time when debugging. Debugging means finding and removing bugs/errors in your code. If your code does more than one thing, get is working in parts. How can you break down the problem?
An effective way of splitting your problems into bits is to write an algorithm. An algorithm is a finite sequence of steps to perform a specific task. To write an algorithm for your code, first define the problem. After that, proceed to writing out the steps to solve the problem. Example: An algorithm to calculate the average of 3 numbers.
- Get the values of the numbers.
- Calculate the sum of the numbers.
- Divide their sum by 3.
The sample algorithm above is an example of what an algorithm is. It can get more complex depending of the nature of the problem. After writing the algorithm, drawing a flowchart is next. For the sake of this article, I would be elaborating more on flowcharts in my next article. Just in case you are wondering, a flowchart looks like this.
In a nutshell, Learning to break down problems into to bits is a skill that is expected of every programmer.
6.Move on to more advanced stuffs.
This is where you start applying the basics. You learn to start writing your code in functions - the idea of code reuse, learning functional programming and object-oriented programming(OOP). You don't have to learn all this things at once. Take it one step at a time making sure you understand.
7.Read other people's code
You might wonder why this is necessary. It would help you see how people write code in large code bases. It might seem overwhelming at first, but trust me, you'd get used to it.
You don't have to know everything about a programming language. Once you know the basics and you understand core programming concepts, you'd do just fine.*
Thanks for reading :)