Let’s start with three philosophical questions: what are grammar and semantics? Why do we need to know grammar and semantics? How do we know grammar and semantics?

What are the syntax and semantics

Any programming language is inseparable from the syntax and semantics, small white feel related to philosophy, can be associated with the “book of changes” of Yin and Yang, or 0 s and 1 s of binary computer, understood as a subordinate objects within the territory of the benchmark, from the beginning, all things are finally beginning, also is the syntax and semantics is the benchmark of a language, language beginning, also ended in this, here is the definition of a closed loop, It’s a little abstract. The Nature of Computing: An Inside Look at Programs and Computers

To fully define a programming language, we need: syntax, which describes what the program looks like; Semantics, describing the meaning of the program. “The Nature of Computing: An Inside Look at Programs and Computers.”

According to this interpretation, syntax and semantics solve two problems:

The first is what a programming language looks like (external constructs), for example to distinguish between a= b+ 1 being a programming language and a=%&$#b+ not.

The second is what it represents (internal structure). For example, if a = 1 * 2 + 3 * 4, it means that the value of A is (1 * 2) + (3 * 4), not (1 * 2) + 3) * 4, and not any other value. Any language can be set on the syntax and semantics, but the emphasis will be different, such as China to study Chinese will be more focus on semantics, more don’t care about grammar, just need to know semantics, grammar is all sorts of subject-predicate bing, fixed shape, fixed sentence patterns, etc., on behalf of the Chinese it just looks like this, and semantics is represented by a Chinese emotions, data, signal, etc., It allows for all kinds of communication between people.

Think about these two things when you’re learning a language, like English, what clauses look like, what they stand for, and does it suddenly feel interesting? To summarize, the syntax and semantics of a programming language are:

Grammar, what does it look like — external structure

Semantics, meaning expressed — internal structure

Why do you need to know syntax and semantics

Why do programming languages talk about syntax and semantics? Deep nature of language is the answer to, if you only stay on the surface of the grammar of the language, so only at most will use this language, its internal mechanism of the use of any resource and you are fuzzy, as even if you know more than N English clause sentences, but you don’t know why there are so many, where is the difference between, what time will limit, etc., so still don’t use English. If you get down to the basics, you can see into the language, its strengths and weaknesses, which platforms it really works on, what content it uses in what situations, and even reinvent the language. If language is compared to a tree, the whole structure from root to leaf can be understood thoroughly, including its varieties, living conditions, growth and so on. So if you love and need the language, study its syntax and semantics.

How do I make sense of grammar and semantics

To understand the syntax and semantics of a programming language, White suggests doing several ongoing things:

1. Keep reading books, articles, information about the programming language. The goal is to continue to strengthen and update the brain memory, many don’t often remember grammar, semantics is more according to context, if you use for a long time the language some aspect or specialty, such as other knowledge will be slowly forgotten you, it is recommended that, regardless of old and new books and popular unpopular, the article generally want to choose a mature platform to prevent copying and low quality, Information selection authority platform to prevent false rumors.

2. Always compare the same knowledge points in different books. Each book of the same description and presentation of knowledge points have individual difference, such as the C language deep anatomy, showed no relationship between arrays and Pointers, and the C program design – Tan Haoqiang indicates an array and pointer to shake off its entangled relationship with and did not say clear, perhaps with the syntax and semantics of thinking to think can get the answer, at this time have to compare the difference, Figuring out which of these differences exists and trying to explain which one is true will, over time, lead you to your own ideas about programming languages at a deeper level.

3. Be curious about authority challenges and knowledge. Believe books is better than no book, also people write books, there are any errors, when himself to a knowledge don’t understand, it would be wrong to try to make bold assumptions about this knowledge, be careful to find counterexamples prove, when trying to use a variety of methods can prove, often to know the essence of knowledge points, learn to challenge authority, self-study learning will become more independent.