Syntactic sugar

related topics
{math, number, function}
{system, computer, user}
{language, word, form}
{theory, work, human}
{food, make, wine}
{@card@, make, design}
{style, bgcolor, rowspan}
{disease, patient, cell}

Syntactic sugar is a computer science term that refers to syntax within a programming language that is designed to make things easier to read or to express, while alternative ways of expressing them exist.

It makes the language "sweeter" for humans to use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

Specifically, a construct in a language is called syntactic sugar if it can be removed from the language without any effect on what the language can do: functionality and expressive power will remain the same. All applications of the construct can be systematically replaced with equivalents that do not use it. For instance, in imperative programming languages, for loops can be systematically replaced with while loops, which in turn can be systematically replaced with gotos.

More generally, the term is used to characterize syntax as being designed for ease of expression. For instance, in C#, the property construct may be called syntactic sugar: it is roughly, but not exactly equivalent to a getter-setter pair of functions. Even more broadly, programming languages have been called[by whom?] "machine code with a lot of syntactic sugar", which is actually incorrect since the concept of syntactic sugar is applied within a programming language, and not between different languages.

The term was coined by Peter J. Landin, when he was working on a lambda calculus enriched with a few operations, such as assignment.[citation needed] Following Landin's insights, some later programming languages, such as ML and Scheme, were explicitly designed as a language core of essential constructs. The convenient, higher-level features could be "desugared" and decomposed into that subset. This is, in fact, the usual mathematical practice of building up from primitives.


Full article ▸

related documents
CLU (programming language)
Intersection (set theory)
Heaviside step function
Bézout's identity
Polynomial time
Euler's criterion
Partial fractions in integration
Magma (algebra)
Alternative algebra
Decision problem
Separated sets
Regular space
Real line
Twin prime conjecture
Whittaker–Shannon interpolation formula
Topological ring
Goldbach's weak conjecture
Algebraic number
T1 space
Kernel (category theory)
Stirling number
Amicable number
Regular language
Dyadic rational
Cayley's theorem
Ordered field
Metrization theorem