DEV Community

Hexalore
Hexalore

Posted on

Syntax vs. Semantics

Syntax? Semantics? What's the difference? Let's break it down.

Syntax

It's the format we follow when we code in a particular programming language. Here are some examples:

Python

print("Hello Gel")
Enter fullscreen mode Exit fullscreen mode

C

#include <stdio.h> 
int main() { 
printf("Hello Gel"); 
return(0) 
}
Enter fullscreen mode Exit fullscreen mode

Semantics

Semantics, on the other hand, is about the meaning or logic behind the code. It’s the formulation of how a program should behave. The logic can be expressed through:

  • Algorithms
  • Pseudocode
  • Flowcharts

Top comments (0)