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?
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.