Syntactic Sugar

What Does Syntactic Sugar Mean?

“Syntactic sugar” is a term for syntax changes in computer programming which make it easier for humans to code. There are several different types of syntactic sugar and synonyms include “syntactic saccharine” and even “candygrammar,” which is often used to describe superfluous or unhelpful “syntactic sugar” changes.


Techopedia Explains Syntactic Sugar

People often define syntactic sugar as changes that make computer programming languages more like English – helping less tech-savvy people to program. However, others also describe shortcuts that consolidate programming tasks in fewer characters as syntactic sugar as well. Sometimes both of these are incorporated in the same change – other times they are at odds with each other. For example, if a syntactic sugar for the unskilled programmer is a command like “make X equal to one” and the skilled programmer shortcut is “X = 1,” both of these could be considered syntactic sugar in their own ways. One simplifies the task for the non-tech savvy person, but expands the amount of syntax needed to complete the task. The other provides a simplified shortcut, but is more cryptic and obscure, making things harder for the unskilled programmer.

In general, syntactic sugar is seen as a lazy way to approach syntax design. The best practice, according to many skilled programmers, is to create a consistent syntax that is efficient and stands up well to change.


Related Terms

Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.