What is a programming idiom?

后端 未结 10 2050
一向
一向 2020-12-04 06:42

I see the phrase \"programming idiom\" thrown around as if it is commonly understood. Yet, in search results and stackoverflow I see everything...

From micro:

<
10条回答
  •  日久生厌
    2020-12-04 07:30

    An idiom is a 'pattern' that can be identified in several places.

    I wouldn't say it has anything to do with a particular programming language.

    Iterator foo;
    foo.reset();
    while (foo.next())
    {
        print(foo.value());
    }
    

    That is a snippet of what i would call the 'for each' idiom which is expressed slightly different in a number of languages.

    Another excellent example of an idiom is Socket. All platforms that claim to have sockets, all work in conceptually the same way, that is, they all have roughly the same interface.

提交回复
热议问题