Idiom Or Pattern

I'd like to offer up this pragmatic definition of both Idiom and Pattern:

    Idioms relate to code
    Patterns relate to design

Examples of simple patterns are 'Factory', and 'Observer'. Examples of idiom would include the most common way of writing an infinite loop (using where(true) rather than for(;;)).

The word 'Idiom' should be translated as 'standard practice'. That is, if one were to look through a number of java systems looking for the solution to a specific problem then the most common solution would be considered 'Idiomatic'.

A pattern is similar, but is specifically related to 'design', rather than code. Also, a pattern doesn't have to be in common usage before being considered as a pattern; it can be a new idea -- an idiom, by definition, /has/ to be an old idea.


What's the difference between an idiom and a pattern? I have a hypothesis that:

Consequently, I have another hypothesis that patterns are big idioms. I'd like pattern folks to declare yea or nay.


I would state the converse, that idioms are merely small patterns. I think that pattern is the more general term. --KyleBrown

I'd agree. Idioms were the ideas used to guide the design and implementation of frameworks like ET++ and InterViews, and DesignPatterns was the result of those developers getting together after the fact and writing down what they learned in a more formal and collective manner. --ScottJohnston

Idioms are language-specific in that the problem they solve, or the context in which those problems are encountered, are caused by the language. Taking the JavaIdioms as examples, InterfacesForDefiningConstants or ClosuresThatWorkAroundFinalLimitation make no sense in any other language. On the other hand, some of the other patterns listed as JavaIdioms probably have wider applicability and so are more than just idioms; ValueObjectsShouldBeImmutable or CrossSection come to mind. Others are probably general patterns that are described in such a Java-specific way as to hide their generality: ParameterClasses could be generalised to refer to any dynamic loading mechanism, for example. --NatPryce

Idiom: an expression in the usage of a language that is peculiar to itself either grammatically (as no, it wasn't me) or in having a meaning that cannot be derived from the conjoined meanings of its elements (as Monday week for "the Monday a week after next Monday") -- Webster.com


We expect patterns to connect and flow into one another in the course of production. When this happens we say that the patterns form a PatternLanguage. We do not expect the same interaction between idioms, nor do we get it from the 23 DesignPatterns made famous by the GangOfFour, and hence the confusion. -- WardCunningham

If a set of patterns form a PatternLanguage, could that language have its own idioms? Has this been observed in the wild?


I'd claim that idioms pre-date patterns, and agree that they are indeed language (including software language) specific. I recall a wonderful collection of APL idioms back in the 70's. (Wish I could recall the author.)


There's a famous collection of APL (AplLanguage) idioms called "The FinnAPL Idiom Library", first published by the Finnish APL Association, Helsinki, 1981 at http://www.pyr.fi/apl/texts/Idiot.htm (That's a Finnish site, so "Idiot" is more likely to be a typo they made than a pun they made.) There was also a paper "An APL Idiom Inventory" by Howard A. Peel in 1987. Also "APL Idioms", IBM-APL User's Club, Japan, 1984 and "Programming with Idioms in {APL}", Alan J. Perlis and Spencer Rugaber, in "APL Quote Quad", Jun 1979, vol 9 no 4 pp 232-235. --DougMerritt

J, a successor to APL, is especially well suited to idomatic usage. Learning the language would require some effort, but, one can appreciate this particular aspect of the language by just browsing the JayPhraseBook.


CategoryIdiom


EditText of this page (last edited December 10, 2007) or FindPage with title or text search