dictionary.com gives 5 meanings for idiom:
  1. A speech form or an expression of a given language that is peculiar to itself grammatically or cannot be understood from the individual meanings of its elements, as in keep tabs on.
  2. The specific grammatical, syntactic, and structural character of a given language.
  3. Regional speech or dialect.
    1. A specialized vocabulary used by a group of people; jargon: legal idiom.
    2. A style or manner of expression peculiar to a given people: “Also important is the uneasiness I've always felt at cutting myself off from my idiom, the American habits of speech and jest and reaction, all of them entirely different from the local variety” (S.J. Perelman).
  4. A style of artistic expression characteristic of a particular individual, school, period, or medium: the idiom of the French impressionists; the punk rock idiom.

sense 1. seems like it could apply to code that is difficult to understand but in fact it cannot apply: the meaning and action of any piece of perl code is always able to be discerned from the individual elements (if one understands those elements thoroughly enough)- take a look at Re: camel code (SPOILERS!) for an example :) If it can be run by perl (the program) then it can be understood. I am not saying it is OK to write production code that is unclear or obfuscated, just that the word "idiomatic" is the wrong word to describe such code.

sense 2. As Abigail-II pointed out this is what is usually meant by idiom when discussing programming languages. I used to occaisionly resort to wrapping perl 1 line filters in shell code because I didn't have the perl in-place edit idiom in my tool kit. I have seen quite a bit of perl code which I have been able to say (with some accuracy) if the coder was a shell or C or "other" programmer. If you are not using Perl idioms then what language are you programming in?

senses 3-5 don't really apply to programming.

I'm not sure what the connection between idiomatic perl and cargo cult programming is supposed to be. The idiomatic perl solution would generally be a briefer and more concise version of the non-idiomatic version, which is opposite to the cargo cult method of "ritually including code which serves no real purpose". I ritually include cgi.pm in my cgi scripts (without attempting to understand cgi.pm), that is not cargo cult programming because cgi.pm serves a purpose and there are good reasons why it is better than other solutions.

Does obfuscation belong in production code? Definately not. Where is the line between obfuscation and a language idiom? I'm not entirely sure :) If in any doubt comment or re-code clearer.

--
Life is a tale told by an idiot -- full of sound and fury, signifying nothing. William Shakespeare, Macbeth


In reply to Re: Idioms considered harmful by greenFox
in thread Idioms considered harmful by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.