Syntactic Salt

Syntactic Salt is the opposite of SyntacticSugar -- a language syntax or construct that detracts from the expressivity of the language. Sometimes this is a simple omission in the language, such as perl's inability to subscript strings as if they were lists, but usually it refers to the extreme verbosity required to express simple things, or just bizarre syntax that doesn't fit into the language. Java's foreach syntax, itself intended as syntactic sugar, is sometimes regarded more as syntactic salt for its strange appearance.

true. . . strcpy(szDestText, "so true"); . . . See "harmful syntax" in SyntaxVsSemantics.

Apparently the coiner of SyntacticSugar, PeterLandin, also referred to "syntactic rat poison" -- syntax that doesn't just detract, but outright kills.

What does it say that we've got

on one hand, and

on the other?

SyntacticSugar is usually meant in an unflattering sense, so is it so surprising that it's all downhill from there? :-)

On the other hand, GoodNotationIsValuable.

(I think there ought to be a SyntacticSaccharine? in there somewhere... it's a little like sugar, but it doesn't really provide you any benefits.)

If syntactic sugar is called sugar because it sweetens working with the syntax, i.e., saving your energy, then SyntacticSaccharine? would only give you the feeling of saving your energy. You may save some typing, but this saving will be undone later when you maintain, refactor or extend. For example, the JavaLanguage 'foreach' construct: Because you cannot obtain the implied iterator, you quite often have to switch back to the normal 'for' construct. Real syntactic sugar works in all cases.

What about SyntacticDarkChocolate? I would define that as syntax that seems like salt at first, but actually makes things easier in the long run, like, after you've been programming for a while. My example: Use asignment to a default variable, say '_', to implement CeeLanguage's asignments are expressions, like so: c = (_ = a = b) * 3 (assuming here that this language supports multiple asignment, but not AssignmentsAreExpressions.)
CategoryProgrammingLanguage

EditText of this page (last edited February 13, 2010) or FindPage with title or text search