How To Learn To Code – A Complete Guide – Part 1

computer coding

Why is knowing how to code so important?

If you imagine yourself sitting on a beach, looking at the waves in front of you, you might see 2 to 3 small waves gliding in your direction. Now, imagine that suddenly you noticed this MASSIVE wave at the horizon. I’m talking about a wave so high, that as it comes closer, it starts to block the sun. A huge, 100ft wave. 

Now let’s say you could very quickly learn to surf. But with a catch. 

You were only allowed to learn to surf ONE wave. 

Now there are 2-3 small waves close to your position, but behind that is the MASSIVE wave that you know KNOW is coming at full speed. Which wave do you want to learn to surf?

That big wave is the technology wave. And the way to surf it is by becoming highly technologically literate. The most fundamental way of doing this is by learning to program computers, the fundamental tools that will power this wave.

What is coding? (You already know)

Believe it or not, you ALREADY know how to code. 

Coding is simply giving directions, something you have probably done all your life, with the only difference being that with coding, you are giving directions to a computer instead of another human being.

A set of directions is a ‘program’ for the person who you gave them to ‘run’.

If you were in a situation where you had to give a person who spoke a different language to you directions, what would the major problem in that be? Would it be that you did not know how to give directions, or would it be that you did not know how to give directions in that person’s language?

It would be the language. 

In the same vein, your problem right now is NOT that you don’t know how to ‘code’ (give directions). It’s that you do not know how to do it in the language of the computer. 

Therefore, coding is giving direction to a computer through a special language.

And that’s all you need to learn.

You already know how to code.

With this knowledge, then, it is clear what you need to learn. The question is how.

What does day to day coding consist of?

As any professional coder will tell you, most of the coding is ‘re-coding’, or bug-fixing as those coders will refer to it. 

Just as a professional writer will tell you that most of the writing is rewriting. 

The most important thing that a coder must get used to is the process of trying something, getting it wrong, correcting that, and then trying again. This along with knowing that it is actually a fundamental part of the process and realising that with each try/fail loop that you do, you ultimately become a better programmer. 

Every failure returns an equally beneficial gift. Coding is about fundamentally getting comfortable with that. 

The general ‘trying’ part of coding itself consists of what we mentioned previously. That is, giving directions that a computer is to follow, in the form of a ‘program’. In the same way, as mentioned above, you give directions to a person as a ‘program’ that they can run.

What skills and mindset do I need to code successfully?

The primary skill involved in coding is the skill of accurately giving directions. But, also the primary hurdle you’ll come across when you’re trying to give a non-conscious (we hope!) computer instructions, is that the computer accepts EXACTLY what you give it. In other words, it’s not very bright. And so you, being human, will make mistakes when communicating your directions to the computer, and so a big part – my experience has been 80±% of the work is correcting mistakes, or bug-fixing as it’s called in the professional field.

So then, finally, what ARE the elements of code, in the form of a programming language?

Just as a language like English is simply a pattern of expressions composed of certain elements that come together (words, numbers, punctuations, etc). Programming languages are the same. 

Below are the key elements that you’ll need to, together, construct a workable program. 

(a) Strings

Just as there are words to represent a collection of letters in the English language, a ‘string’ represents a collection of characters within a program. This collection is always displayed within either double quotes – “an example string” – or within single quotes ‘an example string’. They must be contained within these quotes because, as we mentioned above, the computer is not very bright, and needs clear demonstration that what you are referring to is a string and not something else. 

The key difference between strings and words however is that strings are not commands, directions or instructions, whereas words CAN be. They are simply representations of collected text. Ie in Facebook’s code, your login email address or username would be represented as a string. 

(b) Numbers

Just as there are numbers in the English language for mathematical purposes, there are numbers in programming languages for the same thing. These numbers are divided into two types. You’ve seen these before, but they are named specifically within programming languages as integers and floats. 

(a.1) Integers

Integers are simply whole numbers that don’t have any decimal places such as 1, 25, or 1210.

(a.2) Floats

Floats, on the other hand, are numbers that DO have decimal places attached to them. Such as 1.5, 2.9, or 182.2.

Numbers are used within programs to perform mathematical operations such as to calculate a users date of birth for example. 

(c) Variables

If the purpose of a program is to manipulate data, then Variables are the containers that hold that information for you. They are like taxis and the data, like you, is the passenger. The types of data that the variable holds are elements such as the simple data types that we’ve defined above: strings, numbers and even functions (which we’ll define and explain below) can be held and manipulated inside of a variable. 

Here’s an example of a variable holding an integer:

x = 1;

The variable ’x’ is now holding the number 1. I can now manipulate that 1 that is held within this ‘x’ variable. Like so:

x = x + 1;

x is now equal to 2. 

(d) Conditional Statements

If, as we’ve mentioned above, a program is simply a set of directions. We have to ask exactly what directions are. 

Directions are simply steps or instructions, as well as conditions. So for example, if I was to direct you to a place that had a turn, I would tell you to walk ‘until’ you saw the turn, or maybe a landmark at the turn, and then take maybe a left or a right. So within those directions is an instruction (walk until you see a turn), and there is a condition (IF you see the turn, or maybe a landmark of some sort, turn left or right). These two elements (instructions and conditions) are the building blocks of directions. 

Now, back to programming. As we’ve said, a program is simply a set of directions given to a computer. So when we talked about variables, we say that to define a variable, we have to give an instruction that puts that data we want the variable to hold, inside the variable (x = 1;). So this is an instruction. 

So now, and remember that directions are just instructions and conditions, how about conditions, what do they typically look like?

They typically look like this

If (x == 1)

{

alert(‘x equals 1’); 

}

else

{

alert(‘x does not equal 1’);

}

This condition does a check to see if our variable x is equal to 1. If it is, it alerts ‘x equals 1’ to the screen, and if it doesn’t, it alerts ‘x does not equal 1’ to the screen.

This is a simple condition. Your programs will be made of these as well as the instructions. 

What is next

In the next version of this post, we will be talking about the fifth and final element that is present in every coding language. And that you need to know. That element is called ‘functions’. We will show you how we use them to bring everything we’ve learned so far together, to create a complete, fully functional program.

Stay tuned!

About the author

Tapha is the Founder of FromToSchool (https://fromtoschool.com), a coding school that publishes books, video courses and tutorials that aim to teach professional programmers new languages and frameworks faster, by using the languages and frameworks that they already know. He also teaches a free code class at https://www.facebook.com/CodeClass-Gambia-404509946985658/, where he has so far taught over 200 students how to code from scratch.

About Guest Writer 155 Articles
This article was written by a Guest Author. For more information about this author, please see the bio information listed in the article. If you would like to write an article for us, please visit our Guest Posting Guidelines page.

Be the first to comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.