Syntax alternative in a programming language. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Syntax alternative in a programming language.

Why do programming languages use different alternative but equivalent syntax for expressing the same statements? Example in c++, the following codes are equivalent 1. if (y<a){ x = b;} else {x = c} 2. x = (y<a)? b: c; What is the advantage of doing this? Could this be source of difficulty in learning programming language?

25th Sep 2019, 12:33 PM
Tamirat T.
Tamirat T. - avatar
1 Answer
+ 2
This is a „feature“ of many programming languages. It is called „syntactic sugar“ which means, programming languages are made „sweeter“ by offering additional syntax, to make things easier. Some people criticize these features, because it makes programming or code analyzing more complex.
25th Sep 2019, 2:52 PM
Michael
Michael - avatar