How to Learn Programming - Complete Guide
Though this tutorial may be aimed specifically at new programmers looking to get into the world of programming, it can also apply to those who already know some languages and can help in learning a new one.
So, to give a brief overview of what I'll be covering in this tutorial, here is a table of contents.
- Picking a language
- What to focus on
- How to go about practicing
- Overall good study habits
I will also attempt to go pretty in-depth on most of these and hopefully make learning programming easier for some people.
I will bold any important terms throughout the rest of this tutorial.
In my opinion, this section will likely be the most important for a new learner and will get you set in the correct mindset.
For starters, I typically see people who want to learn to program, expecting to open a terminal in dark mode and remake google in 10 minutes. I get that this may be an exaggeration, but I can't tell you how many times I have seen posts like this on ask:
I don't get any of this weird coding stuff, it doesn't do anything and there is a stupid output thing. I want a search engine!!
So my aim in this section will be to go over things to do BEFORE writing your first line of code.
First things first, you should be comfortable knowing how a computer works and should understand how a computer interprets things. I'm not a hardware engineer, but in my opinion, you should know a few of these topics:
- Hardware vs software
- What a CPU is
- How a CPU works (this is a little complex but a small overview could be of help)
- Local vs cloud
- Storage and memory
- The internet, the web, and wifi
- What binary is
I'm not looking to teach all of this, but I definitely recommend that you google some of this and just get a general understanding, nothing too crazy.
Now that you know about computers in general, let me give you a small overview of the difference between computer science and programming/coding.
As the name suggests, computer science is the science of computers. If you think back to science, it is a lot of understanding how things work and very general topics, such as algorithms or compiler design. Notice how not once in this little explanation of computer science have I mentioned anything about writing actual code, or programming languages. That is due to the fact it is a very generalized topic and that it doesn't matter what programming language you use.
But which one should I learn?
To answer that, I would say that both fields almost have a somewhat of a symbiotic relationship as they rely on each other. What I mean by this is that you can have a brilliant programmer who knows 10 different languages, but can't write a simple sorting algorithm due to their lack of computer science knowledge. This applies to computer scientists also, as they could be coming up with groundbreaking algorithms but would have no experience turning them into code, rendering their work useless.
Lastly, don't expect this to be an easy journey. Truly becoming a good programmer takes time, a lot of it.
Note: keep in mind that everything in this tutorial is just my personal opinion and isn't objective
So now that you have hopefully completed your preparation in getting ready to program, you can start by picking a language. I would like to guide you in the best overall language so let me list some of the popular ones to start with:
- Malbolge (I'm joking don't worry)
Note: if your learning programming out of wanting a job or money, not passion, then just learn Python and Python's NumPy and your set.
Personally, for me, I think the best way to start is to eliminate a few langs and then chose which one best fits your interests. As a beginner, I would immediately eliminate Ruby and Java as Ruby is for mostly the web, and Java is just somewhat outdated.
From there I would eliminate Python which will probably anger 95% of replit, but I can give you a good reason why. Firstly, Python was my first language and is still probably my best one, which shows that I don't have any bias against it. My main reason for ruling out Python is that it is simply too high-level and has an inbuilt function for literally everything. This serves as a major disadvantage for new programmers as it deprives them of many skills and makes it a million times harder to switch to another language. On top of that, Python is just too easy to learn, giving you a nightmare when trying to learn something like C.
Note: my transition to C (still happening) felt a bit easier as I focused a lot on logic with Python. Also, I would like to mention that Python isn't really bad but rather is not something for beginners to start with.
Now that Python is out of the way, we are left with C, C++, C#, and JS/HTML/CSS. This is the point where it goes down to personal preference as it becomes industry-specific. Anyone looking to make websites or front-end related programs can choose JS/HTML/CSS as they are the three languages that make up the web.
If you got to this point, it probably means that you want to be a programmer and that you have clear goals set for yourself. This is good and let me quickly give you a run-down of the three C languages allowing you to make an informed decision.
- C: Low-level general-purpose language, overall fantastic and gives a good foundation.
- C++: Same thing as C except slightly modernized.
- C#: Mid-level, overall good starting point. Used in game-dev with Unity.
Personally speaking, I would recommend C or C++ as low-level languages are the best to start with and will make learning other languages much easier. C# isn't bad either so if you're looking into developing games, it's the way to go.
If you want something a bit more in-depth on why C is so good here is a tutorial by @MocaCDeveloper (sorry for the ping): https://replit.com/talk/learn/What-language-to-start-off-with/138596. This tutorial is great at explaining the advantages and further shows why Python is a bit overrated.
Note: this is completely my opinion and it's totally fine whatever language you picked as the rest of the tutorial is not language-specific.
Now that you have a language in mind that you want to start with, I would like to cover what to specifically focus on when starting your learning journey. For starters, I'll explain the difference between syntax and concepts as it will pretty much be the foundation for this section.
Syntax is a set of rules, almost like grammar which is used to create a certain program. Syntax often varies from language to language and has to be learned in connection to a programming language. Here is an excerpt from Wikipedia for further reference:
In computer science, the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be correctly structured statements or expressions in that language. This applies both to programming languages, where the document represents source code, and to markup languages, where the document represents data.
Concepts on the other hand tend to be more generalized and carry over from language to language. To give an example, something like sorting an array would be considered a concept as it's pretty much the same idea no matter what language you use.
Here is a good further reference for syntax vs concepts.
Now that's out of the way, I would like to discuss exactly how to make the most of your learning. To start, you should first focus on learning the syntax as it's impossible to code without knowledge of syntax. If you're wondering where to obtain this, most languages have a documentation page explaining or you can use free online websites like w3schools or programiz.
After learning syntax, you must learn to think logically as programming is about solving problems not coding. For example, if I asked you to find the index of an element in a sorted array, how would you go about solving that? Think about that for a bit, and see if you can come up with a decent solution.
I'm assuming that most of you would have thought to just iterate through the list keeping a counter until you fall upon the element (called linear search) something like this:
Note: keep in mind that indices in arrays start with 0, not 1. Also, this isn't code but rather a way to walk you through the thought process.
array = [1, 3, 4, 5, 8, 10, 11, 13, 16] target_element = 11 counter = 0 iteration1: 1 is not equal to target_element, counter = 1 iteration2: 3 is not equal to target_element, counter = 2 iteration3: 4 is not equal to target_element, counter = 3
I won't write out the whole thing, but hopefully, you get what I mean. Now moving back to my point of solving problems, this same thing could be solved in a much more efficient way by splitting the array into halves (called binary search) like this:
Note: This GIF shows both methods. Also, I used a GIF as it makes it easier to show exactly how a binary search algorithm works.
By looking at the GIF, you can see how the binary search only takes 3 iterations to locate the element while the linear search takes 11, almost 4 times as slow.
My point here is that you should be focusing on the concepts more than the syntax as they carry over from language to language and are invaluable pieces of knowledge to have. That said, you shouldn't be ignoring syntax because it still happens to be important when writing programs.
You also should be looking to fully understand every new idea you learn as I believe that quality over quantity is an extremely essential rule to follow when learning anything in life.
Throughout this tutorial, I have remained generally vague and haven't gone into detail on the topic of practicing. To address that, I want to cover a sort of flow chart when practicing and how to practice effectively.
To start, in my opinion, the best way to practice as a beginner, intermediate, or pro, is to solve small challenges which will slowly build your skills. For example, taking up a big project from a random tutorial often confuses beginners and makes them learn nothing apart from copying and pasting code. This can be alleviated, through the use of challenges that are bite-sized and only take 15 or so minutes.
If you're wondering exactly what a small challenge would look like, here is a basic one of finding a duplicate in an array. To solve this, one must first ** break down the problem into small steps** before writing any code. Here is a flow chart to represent that:
1) Creat main array and an empty array 2) iterate over the main array 3) Check if the element is in empty 4) if it is, its the duplicate 5) Otherwise, add that element to the empty array
Note: I know that there are more efficient ways to do this such as iterating through the array simultaneously or by using Floyds's turtle and hare algorithm, but I just want to keep it simple for now.
Now that we have the steps in mind we can turn it into pseudo-code, making it easier when doing the final conversion to a language of choice. For anyone wondering, pseudo-code is plain text that details the steps of an algorithm in a more programmatic way.
The pseudo-code should look something like this:
array = [3, 2, 5, 4, 5] empty_array =  iterate array as element if element in empty_array element is the duplicate else add element to empty_array
From here it is up to you to convert it to a programming language, but the problem itself has been essentially solved simply and clearly.
Believe it or not, this method even works in large projects, as you can split the project up into small components and then split the small components further into rough steps. This makes these projects a lot less intimidating and will overall simplify the programming process.
Note: If your working on a big project, please don't go and write the whole thing in pseudo-code, save yourself some time.
Here is a list of websites that provide great challenges to practice on:
- Edabit: Has specific language sections and sorts by difficultly making it perfect to work your way through
- Project Euler: Much more difficult than the other ones but provides a great challenge to experienced programmers and is very math-based.
- HackRank: Has a lot of challenges and languages and is an overall good option.
- LeetCode: Haven't tried it yet, but have heard that it's pretty good so maybe check that one out.
- My profile: This one isn't a website, but I have done around 175 challenges in C and Python which could be good ones to attempt. (Some of my solutions from earlier are awful)
This section will be pretty quick but I want to jot down some habits to follow when programming to make learning more efficient.
Avoid Burnout: This one might seem simple and self-explanatory, but you would be surprised by the number of programmers who dedicate themselves to coding 10 hours a day but still can't learn anything. This goes back to the saying, quality over quantity, as there is nothing special in coding 10 hours a day to show your dedication. In my opinion, programmers like that are no smarter than any old monkey as they think the longer they spend mindlessly doing something the better they will get at it. Overall, what I'm trying to say here is to shut down your computer and stop coding the second you feel like you not productive anymore.
Code 30 minutes a day: This one ties in with avoiding burnout as programming 30 minutes a day will not only keep you from getting burnout but will also build consistency. Consistency in anything is key as it works to build a habit, something that will constantly keep you learning whether you feel like it or not. Personally, I was able to build consistency through doing one challenge a day and making a repl called: "Your lang project number something - the name of the challenge". Before I knew it, I had over 150 of these challenges each helping me keep up my streak.
Exercise: Though not directly related to programming, exercise is a must as it makes the human body feel more productive while, at the same time keeping you fit. It also helps you avoid that typical programming setup where you're sitting in your chair with junk food coding endlessly for hours wasting your time. By taking breaks to go and exercise, you will be able to recharge your brain, body, and your general health.
Take Breaks: I know this may seem like a break in discipline, but trust me, taking breaks from the computer itself is probably the best way to learn something new or solve a problem. What I recommend is to study/code for 20 or so minutes and then go take a break and go for a walk. Believe it or not, this often allows your brain to get refreshed and come up with a solution to a problem you have working on or a new concept that you have tried to learn,
Look at old code: This may not be directly a study tip, but it often helps to look at old code and think just how bad you used to be. This is something I do all the time to motivate me as it shows how far I have come and have progressed.
This is probably one of the hardest things for a person to acquire when learning anything as people tend to be excited on the first day and have a great time but then slowly slide away and stop learning together. My go-to solution for motivation is consistency because eventually you will lose the need for motivation and will program out of pure muscle memory.
Ok fine, I know that this isn't particularly encouraging so let me give some other pieces of advice regarding motivation. First things first, on your first day of programming and every day after that, I would recommend setting a 30-minute timer when you code and forcing yourself to stop for the rest of the day after that. This will create a sense of anticipation (like waiting for Friday to come) something that will make you excited for the next day to come so that you can continue what you were doing. This works especially well for beginners as they have the most motivation to start, something great for creating anticipation.
Other than that, coding with friends or other people generally helps also as you can keep each other accountable and have some fun in the process.
One last tip when it comes to motivation is to create a calendar for yourself and mark off a day every time you code. You can use this to build a streak or perhaps offer yourself incentives along the way.
I hope that this tutorial has helped you in some way, and has made the process of learning programming easier. So if you could leaving any feedback/comments would be appreciated as It would help me improve my tutorials.
Note: There might be some typos
You really need to restructure your
What language to choose section. You need to create sections based on what exactly the person wants to do.
- Game Dev? Java, C#, C++, maybe C(Idk).
- Data Science/ML ? Python.
- Frontend Web Dev? HTML, CSS, JS, PHP, TS, CoffeeScript.
- Backend Web Dev? Node.js, Ruby, Go, TS, CoffeeScript.
- Database? MongoDB, MySQL, SQLite.
- IOS Apps? Swift, Objective-C, Dart.
- Android Apps? Kotlin, Java, Dart.
Explain the pros and cons of each one(You don't have to use all the ones I mentioned) because it all depends on the specific programmer.
Honestly, this is actual good advice for beginners. I love how you give concepts its own section because barely anyone actually cares to look at the concepts. Beginners tend to think that programming is about writing down a bunch of stuff but there actually is a lot of concepts required for making the program work. I also love how you talk about learning binary, hardware, the web, and that stuff as the first thing to learn about because I know many people get straight into programming without actually knowing what their code is doing. There is only one statement which angers me:
As a beginner, I would immediately eliminate Ruby and Java as Ruby is for mostly the web, and Java is just somewhat outdated.
Not happy, especially since you put csharp as a good language when its basically just microsoft's java >:(
But hey, thats just opinion lol
@EpicGamer007 thanks for the great feedback! I decided to put in concepts after being active on repl ask for a while cause I was getting annoyed by the amount of questions assuming that syntax is the most important. As for the languages, I completely get your point about Java and csharp but then again as you said it’s just comes down to opinion.
Minecraft: Hello? I'm a popular game being updated very often, and I'm made with Java!
Java is just somewhat outdated
@DillonB07 : Hey! What is one of the most popular games called? Minecraft Java Edition.
Yes, bedrockers, Bedrock Edition does exist (made in C++), but more people play Java, and Java was the original version.
And, in my opinion, Bedrock Edition is rubbish.
@DillonB07 First things first we can both agree that bedrock is absolute garbage. Moving on the reason I say Java is outdated is that most game engines nowadays use c# over a language like Java. The reason Java is still used in Minecraft is that it’s quite difficult to migrate a whole game to a new language rather than to continue with Java. I’m not saying not to learn Java but I would say there are better more modern first language alternatives
Hiya, really nice tutorial, but just a typo i found:
# Chapter 6 - Study Habits
# Chapter 6 - Motivation
You might want to change the numbers ;)
Other than that, super awesome tutorial!