In order to speak a language you need to know its grammar. The same applies for learning a programming language. This grammar, you need to learn, is called syntax in the programming world.
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.
— Wikipedia, read more about syntax
If you want to say something in English, you need to put the words into the correct sequence (order) for people to understand you. Let’s think about this example — you want to say that you are hungry. There is a difference if you say
I am hungry versus
am I hungry. If you wouldn’t know English grammar, you could even say
hungry am I which is an invalid sentence for what you want to say and people wouldn’t understand that they are supposed to give you some food.
As we are talking to people using correct English grammar, we need to talk to the computer using correct programming grammar.
Imagine that you would like to create a new and very simple programming language that can only define a number and then increase its numeric value. You would need to, somehow, tell the computer what to do.
Lets use English language to write that program. Here is an example of a programming language you could make.
create number named myAge with value 25
add 1 to variable myAge
Your new programming language would need to recognize some keywords to be able to translate
create number named into low-level instructions that would command the computer to allocate a piece of memory, big enough to store a number, for the program. The piece of computer memory would be called
myAge and the value stored in that piece of memory would be set to
Do not try to put this code into your code editor yet. You will have an opportunity to learn how to define and modify variables in the next article.
let myAge = 25
myAge = myAge + 1