What Is The Difference Between 'Syntax' And 'semantics"?

6

6 Answers

Iris Phillips Profile
Iris Phillips answered
The difference between syntax and semantics, in short, is that syntax is concerned with the structural, or grammatical correctness of a sentence, while semantics are concerned with the rules attributing meaning to a sentence. The best way to explain this in more detail is to take a look at each term

The basic principle here is word order, which is necessary to give a sentence both structure and meaning. The construction of a sentence or phrase is governed by the rules and prevailing principles applied within the syntax of any given natural language, as well as in languages used for computer programming.

An example of a syntactically incorrect sentence would be: Mice cheese eat. The correct form would be: Mice eat cheese. In computer programming, a syntax error would occur if rules of the particular programming language used are broken.

Semantics give meaning to a sentence by accessing the prior knowledge of the actual meaning of words or symbols within a language. It is language specific and focuses on an individual's ability to distinguish the meaning of words and their relationship to each other.

The above example of: Mice cheese eat, for instance, though wrong in a syntactic sense, still provides a meaning in a semantic sense as an individual will know from their existing knowledge that a mouse eats cheese.

A semantically incorrect sentence would include words or symbols a reader or listener is unable to interpret. To stay with the mice example, for instance, the statement: Mice hoopnod yongadoddle, for instance, may be based on the correct syntax, but has no meaning to anybody, because the last two terms are semantically incorrect and can not be readily interpreted.

The same applies to programming semantics. If symbols used are not recognized by the computer, a semantic error occurs.
Steven Vakula Profile
Steven Vakula answered
Syntax is the way in which we construct sentences by following principles and rules. Semantics is the interpretations of and meanings derived from the sentence transmission and understanding of the message
Anonymous Profile
Anonymous answered
Syntax errors is due to missing colon,semicolon,parantheses etc... .it deals with  the way of writing a prgram

semantics errors are logical errors.due to wrong logical statements It deals with logic of a program..
Anonymous Profile
Anonymous answered
Semantics errors are Logical, Syntax errors are code errors.
Anonymous Profile
Anonymous answered
Explain the distinction between an ambiguity in a proposed algorithm and an ambiguity in the representation of an algorithm

Answer Question

Anonymous