13

I was reading through Groovy in Action, Second Edition and on a footnote, I found the following text

Java pours “syntax vinegar” over such a construct to discourage programmers from using it.

What does the term syntax vinegar means here?

I have never heard of this term before and searched on DuckDuckGo and Google but couldn't find a meaning. But it's being used in multiple places. It would be great if someone can clarify the meaning of this term and how it applies in the context of programming languages. Hope this constitutes as a valid question. Couldn't find any other stackexchange site where I can ask this.

6
  • 17
    I'd assume it's the opposite of syntactic sugar Aug 23, 2017 at 12:28
  • 2
    It means it's a not pleasant or easy to use syntax. It's the opposite of Syntatic Sugar. Edit: @VincentSavard, beat by 54 seconds. :)
    – Machado
    Aug 23, 2017 at 12:29
  • 2
    see Discuss this ${blog}
    – gnat
    Aug 23, 2017 at 12:35
  • 4
    The more usual term for the opposite of syntactic sugar is syntactic salt, but this almost certainly means the same. Aug 23, 2017 at 12:40
  • 1
    Now I am just curious what exactly that were calling syntactic vinegar. Sep 3, 2017 at 6:05

1 Answer 1

18

"Syntactic sugar" is a common term for syntactic constructs added to a language primarily to make certain constructs easier or more pleasant to use.

"Syntactic vinegar" is the opposite, making the syntax for invoking a questionable construct deliberately unpleasant, as a way of preventing programmers from using it unnecessarily, but without going so far as to make it actually invalid.

2
  • 13
    Note while "syntactic sugar" is a common, widely used term, "syntactic vinegar" is most probably an invention by the authors of that book.
    – Doc Brown
    Aug 24, 2017 at 14:07
  • Late comment to note that "syntactic vinegar" is a decades-old term. The earliest instance I've found is 1993 on the difficulty a new programmer would have in understanding a particular construction in Ada. This is a contrast to syntactic sugar in the sense of ease of reading (rather than writing) code. By 2003 Tantek Celik was using the phrase of XML namespaces and by 2006 David Heinemeier Hansson was using it of intentional constructions in Ruby on Rails to discourage behavior.
    – denmch
    May 11, 2022 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.