Jump to content

Talk:Programming idiom

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Talk

[edit]

I'd like to have a category/list of idioms that would include things like Graceful exit, Schwartzian Transform, and so on. I'll have to think about the scope of that first. Joseph N Hall 02:30, 31 August 2006 (UTC)[reply]

Isn't i++ example of Syntactic sugar, and not really a computer language idiom? 80.216.68.41 (talk) 19:05, 25 November 2008 (UTC)[reply]

Parallel looping / traversal of lists or other structures

[edit]

One idiom that has to be "written by hand" in many languages is to step over the members of two or more lists (or arrays, trees, etc.) at once.

In Lisp, there are idioms using DO or LOOP which explicitly allow you to move through two structures at once. In C, you can do it with comma-separated steps in a for(;;) expression, but it's unusual and considered obfuscated; the idiomatic thing is probably to write it by hand in a while loop. In Python, you use tuple unpacking and zip for lists, but for any other structure you'd probably do it by hand (or maybe use iterators). And in Haskell you'd probably lift the traversal operation for the data structure into the list monad. --FOo (talk) 05:45, 10 December 2009 (UTC)[reply]

Idioms also show up in Data Structures

[edit]

Programming idioms also show up in data structures. For example, there are particular ways to express graphs using (say) lists and/or maps. -- RichMorin (talk) 00:58, 1 August 2012 (UTC)[reply]

Merge

[edit]

Some WP:DUP content was trimmed down, but now article looks like a stub. Also, there weren't any sources, so I propose to merge it with bigger topic.

Programming language theory was closets page I was able to find, if there better candidates, I don't mind. Ushkin N (talk) 14:01, 27 May 2016 (UTC)[reply]

These two topics are unrelated and should not be merged. —Ruud 14:07, 27 May 2016 (UTC)[reply]
Then suggest a better parent article. Ushkin N (talk) 14:08, 27 May 2016 (UTC)[reply]
No. It shouldn't be merged at all. —Ruud 14:10, 27 May 2016 (UTC)[reply]

How "Programming idiom" is different from Programming paradigm?

[edit]

Ushkin N (talk) 14:06, 27 May 2016 (UTC)[reply]

A paradigm comes with a whole collection of idioms. Some idioms, like recursion, are applicable in more than one paradigm. —Ruud 14:08, 27 May 2016 (UTC)[reply]
Yes everyone on the Internet says this. Can you provide sources instead of revert warring please ? WP:EW WP:V WP:TRUTHMATTERS Ushkin N (talk) 14:12, 27 May 2016 (UTC)[reply]
Both Turbak's Design Concepts in Programming Languages and Scott's Programming Language Pragmatics use the term "programming idiom" in a manner where it can't be taken to mean the same as a "programming paradigm". Do you have a source that claims otherwise? —Ruud 14:18, 27 May 2016 (UTC)[reply]
Thank you for references (I haven't checked them yet but I trust your claims).
I think we can expand lead of the Programming paradigm with paragraph about "Programming idiom" as "smaller than programming paradigms".
OR "equivalent" (I don't know exactly yet) Ushkin N (talk) 14:31, 27 May 2016 (UTC)[reply]
This way, Programming idiom will have better context.
Also, with your sources, we can extend list of the sources at Programming paradigm. What do you think? Ushkin N (talk) 14:29, 27 May 2016 (UTC)[reply]
"smaller than programming paradigms" is not correct English in this context. —Ruud 14:38, 27 May 2016 (UTC)[reply]
Agree, then how would you paraphrase this? Ushkin N (talk) 14:42, 27 May 2016 (UTC)[reply]
I'd extend the sentence "... according to the style of computer programming" to "according to the style of computer programming and idioms used". Making it fit in a more natural manner would require a more significant rewrite. —Ruud 14:48, 27 May 2016 (UTC)[reply]
I found some discussion about "Design patterns" vs "Programming idiom"
"Design patterns are not usually language specific. Language idioms tend to depend on particular feature of a language (or class of languages) or work around a specific deficiency in said language(s)." - http://programmers.stackexchange.com/a/106819
Some of the users tend to think this is true. We should mention this WP:POV.
I have no preference where to state this. Ushkin N (talk) 14:54, 27 May 2016 (UTC)[reply]

Programming idiom in "Design Concepts in Programming Languages"

[edit]

In the version of the book I was able to find, "programming idiom" used 2 times without definition what "programming idiom" is.

User:Ruud Koot, can you provide direct reference from "Design Concepts in Programming Languages" where it is defined? Ushkin N (talk) 15:41, 30 May 2016 (UTC)[reply]

Programming idiom in "Programming Language Pragmatics"

[edit]

In my version of the book:

  • p 169 ... "Consider the programming idiom illustrated in Example 3.22."
  • p 180 ... "The ML type system, for example (Section 7.2.4), avoids the dynamic type checks of Lisp, but disallows certain useful programming idioms that Lisp supports. Similarly, the definite assignment rules of Java and C# (Section 6.1.3) allow the compiler to ensure that a variable is always given a value before it is used in an expression, but disallow certain programs that are legal (and correct) in C."
  • p 265 ... "In functional languages, the ability to specify a function “in line” facilitates a programming idiom in which the body of a loop is written as a function,with the " <...>
  • p 426 ... " The usual programming idiom looks like this:

if (!setjmp(buffer)) { /* protected code */ } else { /* handler */ } "

  • p 560 ... "This programming idiom—an unbounded generator with a test-cut terminator—is known as generate-and-test." ...

Definition of the Programming idiom?

[edit]

As was stated above, there no source, defining what "programming idiom" is or simply enumerates all "programming idioms" in existence.

Can anyone provide source for Programming idiom? WP:V Ushkin N (talk) 15:54, 30 May 2016 (UTC)[reply]

I came to this page to get a definition of idiom, and it is mostly useless for giving a quick understanding of a programming idiom. Had to read it three times. Here is a definition from stack overflow:

"It comes from idiomatic the meaning of the word idiom in programming can be summed up as phrase that carries meaning and implications that is more than the sum of the words. In programming most code snippets are actually idiomatic. 'Pertaining or conforming to the natural mode of expression of a language'

A Programming idiom can be considered descriptive of a class of solutions that is transferable to different cases. Consider while { ... } vs do {} while these are idiomatic, they contain the same words but the ordering carries an important distinction. The exact phrasing will differ by language, but the fundamental meaning and implications will differ; for example do {} while will always be executed once, no matter what language or statements are used to implement it. As an idiom it is transferable shape of an idea. It could be used in many circumstances, and expressed with different words (statements/commands) but the fundamental result will always be the same."[1]

While technically precise, this article gives no quick understanding of a programming idiom. — Preceding unsigned comment added by Gfsheppard (talkcontribs) 17:09, 30 December 2018 (UTC)[reply]

References

Idiosyncratic = Typical usage?

[edit]

It's suggested in this page that th use of idiomatic, to mean a typical means of doing something (in programming), is incorrect, and instead idiosyncratic should be used. Not only does this fly in the face of idiosyncrasy's definition, but I can't find any other reference to this use of idiosyncratic to somehow mean typical.

Should this be amended somehow? Understandably idiom means something different from its standard definition in this context, but idiosyncratic doesn't seem appropriate either.

Schmake (talk) 22:28, 13 October 2021 (UTC)[reply]

I agree that 'idiosyncratic' is the wrong term here. I think the author of this section has conflated 'programming idioms' with 'programming idiomatically'. I've added a disputed tag for this. Ted BJ (talk) 22:02, 23 June 2022 (UTC)[reply]

Examples are incomplete

[edit]

The list doesn't even contain idioms, those are just basic statements in prog.-langs that anyone would find in the official docs. I suggest we add better examples, and remove the current ones Rudxain (talk) 19:23, 25 April 2023 (UTC)[reply]