I love learning new tech terms, but this one really takes the “cake” (ha, see what I did there?) But yokes aside, “syntactic sugar” is a great way to talk about languages, computer or human.
Syntax is the structure of a sentence or language, providing rules to how a person should read or write a language. Every language is different. For example, in my mother tongue, English, we always put the adjectives before the noun. Like this: “the big, fluffy, red velvet cupcake.” However, the rules for French and Spanish are the different, mostly putting the adjectives behind the noun like this: “the cupcake red velvet, fluffy, and big.”
Programming languages have their own syntax. Frankly, most computer languages are more similar to French in that they define the object (noun: “the cupcake”), then they classify it (class: “big”), and classify it further (adjective: “big”, “fluffy”).
So the syntax of a programming language defines what the program does, so what’s up with the “sugar”?
Here’s the cherry on top: the “syntactic sugar” is a special, easier (most of the time), way of writing in a programming language. It’s like slang–you don’t have to write out the whole thing. There are special syntaxes built into most languages, so once you learn the lingo, you can pour some sugar on it.
Syntactic sugar makes developers lives easier, as well as the people who want to review their code. It makes it easier to read for humans and faster to write. Sugar–yes please.
There are a few intermediate classes coming up in June, so don’t miss your GDI dose!
*Doctors say that one class of GDI a month, keeps the code bugs away! You don’t want to lose your sweet spot for learning!
I learned this morsel of information while practicing some PHP at the lovely Codecademy Website. Thank you for providing such useful information to the public!