7.7. Variety and Syntax¶
Since the first high-level language, FORTRAN, there have been hundreds of programming languages developed. Each new language builds on ideas found in earlier programming languages. Sometimes they are designed just to test a particular idea or just for fun, but usually, a new language includes features designed to make some particular task easier to accomplish.
Each of these languages has its own syntax - the rules that govern what makes a legal statement in the language. Oftentimes languages borrow syntactical elements from each other and thus look similar, but every programming language has differences in what you can say and how you say it.
Human languages have syntax rules as well - in English, we consider “I ate the red apple.” to be a sentence, while “ate. I red the apple” is nonsense. Programming languages have more limited syntax than human languages, but the biggest difference is the listener. We depend on humans to understand things even when there is a slight syntax error in something we say or write; “Let’s eat, grandma” and “Let’s eat grandma” are two VERY different statements, but no one is going to engage in cannibalism because we wrote the wrong one.
Computers are not so forgiving - they are not clever enough to figure out what you meant. If you have an error that violates the syntax of their language they will not even try to execute it. If you have an error that does not violate the syntax of the languages they will try to execute it even if it makes no sense.
Although each programming language has its own rules, there are some basic concepts that most programming languages have in common. There are programming languages that work in fundamentally different ways, but most programs are written languages that all work in a fairly similar way (what is known as the imperative style of programming).