We have often come across this problem. Right?
Well not quite. We choose to ignore them most of the time. But what the hell does this even mean.
Aren't they both the same?
Well ... Not quite. Let's understand why.
Syntax: A syntax tells you what you can write.
Semantics: A semantics tells you what the hell you wrote.
Ha Ha!
For eg.
Value1 + Value2 gives a Value3 in programming. We all know that.
Now this "ValueX" can be a variable, can a constant or maybe something else too.
So,
1 + 2 gives 3. Right? YES!
"Hello" + "World" gives "HelloWorld". Right? YES!
1 + "Hello" gives ???
Exactly ... this is semantics.
You can right 1 + "Hello". This is "syntactically" correct coz you have two values and an operator in between.
But what the hell does it mean? That is what "semantically" means.
Phew!
Top comments (0)