Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the word "semantic" mean in Computer Science context?

I keep coming across the use of this word and I never understand its use or the meaning being conveyed.

Phrases like...

"add semantics for those who read"

"HTML5 semantics"

"semantic web"

"semantically correctly way to..."

... confuse me and I'm not just referring to the web. Is the word just another way to say "grammar" or "syntax"?

Thanks!

like image 239
Hristo Avatar asked Jul 28 '10 16:07

Hristo


People also ask

What does semantic mean in computer science?

What Does Semantics Mean? Semantics in IT is a term for the ways that data and commands are presented. Semantics is a linguistic concept separate from the concept of syntax, which is also often related to attributes of computer programming languages.

What is semantics in computer networks?

Semantic networks are a way of representing relationships between objects and ideas. For example, a network might tell a computer the relationship between different animals (a cat IS A mammal, a cat HAS whiskers). Below is an example image of a semantic network.

What does semantic context mean?

1. Meaning attributed to words due to the content, form, style or origin of a text, rather than by the customary linguistic definition of the word. Learn more in: Land Acquisition and the Semantic Context of Land within the Normative Construction of “Modern Development”

What is semantics in programming with examples?

The Semantics of Programming Languages. Semantics, roughly, are meanings given for groups of symbols: ab+c, "ab"+"c", mult(5,4). For example, to express the syntax of adding 5 with 4, we can say: Put a "+" sign in between the 5 and 4, yielding " 5 + 4 ". However, we must also define the semantics of 5+4.


2 Answers

Semantics are the meaning of various elements in the program (or whatever).

For example, let's look at this code:

int width, numberOfChildren; 

Both of these variables are integers. From the compiler's point of view, they are exactly the same. However, judging by the names, one is the width of something, while the other is a count of some other things.

numberOfChildren = width; 

Syntactically, this is 100% okay, since you can assign integers to each other. However, semantically, this is totally wrong, since the width and the number of children (probably) don't have any relationship. In this case, we'd say that this is semantically incorrect, even if the compiler permits it.

like image 128
Mike Caron Avatar answered Sep 23 '22 21:09

Mike Caron


Syntax is structure. Semantics is meaning. Each different context will give a different shade of meaning to the term.

HTML 5, for example, has new tags that are meant to provide meaning to the data that is wrapped in the tags. The <aside> tag conveys that the data contained within is tangentially-related to the information around itself. See, it is meaning, not markup.

Take a look at this list of HTML 5's new semantic tags. Contrast them against the older and more familiar HTML tags like <b>, <em>, <pre>, <h1>. Each one of those will affect the appearance of HTML content as rendered in a browser, but they can't tell us why. They contain no information of meaning.

like image 28
Adam Crossland Avatar answered Sep 20 '22 21:09

Adam Crossland