Programming Idiom

An idiom is a phrase that doesn't make literal sense, but makes sense once you're acquainted with the culture in which it arose. Programming idioms are no different. They are the little things you do daily in a particular programming language or paradigm that only make sense to a person after GettingIt.


To a native speaker, a language idiom is clear and concise; similarly, to a language expert, a programming idiom is easier to read and comprehend than the "straightforward" implementation it replaces.

Not all idioms are obfuscated, however. Some programming idioms make sense immediately; although the novice could not have synthesized them, s/he can understand them on first encounter. Smalltalk "inject:into:" is an example of a non-obvious idiom, "select:" of a straightforward idiom.

-- BetsyHanesPerry


Actually, I think a ProgrammingIdiom is a small-scale pattern that only applies to a particular programming language -- it may or may not be a code snippet, as KentBeck will attest to. Anyway, I'm collecting them now for Java (JavaIdioms).

-- KyleBrown


I think of multiple-dereference as a programming idiom that spans several languages: typical example is with lists, where the list node has a ref-list field in it and much code passes around a ref-ref-list which is initially where the list header/carrier records the head of the list, but each time I add an item to the (tail of the) list I record it where my ref-ref-list is pointing and revise my ref-ref-list to point to where this new item wants to put its successor. This works in (at least) Algol 68 and C but I still think of it as a programming idiom. Similar tricks work for more complex data structures, so the approach is a pattern (unless I've misunderstood), but it's a pattern of implementation detail, not of design problem-solving. I think. -- EdwardWelbourne


See AntiIdiom


CategoryIdiom
EditText of this page (last edited October 10, 2003)
FindPage by browsing or searching

This page mirrored in WikiPagesAboutWhatArePatterns as of April 29, 2006