...
/Syntax and Building Blocks of a Programming Language
Syntax and Building Blocks of a Programming Language
Learn basic things required to understand a programming language.
We'll cover the following...
The foundation of a programming language
Just as human languages have grammar to dictate the rules of the language, a programming language has syntax. The syntax of a programming language is the rules for how we write a program using a language. There is one big difference between grammar and syntax and that is the forgiveness for errors. If you meet someone who speaks a language you know but makes some errors here and there, you will still be able to understand what that person is trying to communicate to you, and vice versa. This is not the case for the syntax of a programming language, where accuracy is crucial:
Previously, we discussed that the code we write will be translated by either a compiler or an interpreter, and for that translation to work, the syntax should not have errors.
Each programming language has its own syntax rules, but as we saw in the family tree earlier, languages can be related. So, many languages share a syntax with only slight variations, where others have a more specialized syntax. When learning a new language, we must learn its syntax. That is why moving between closely related languages is easier because they will most likely share a lot of their syntax.
If we have an error in the syntax, it will be discovered during the translation, and here is where a compiled and an interpreted language differ. For a ...