Generic programming: Difference between revisions

Content deleted Content added
sfn fix.
Restructure and Clarify the introductory section on Generics and Templates.
Line 12:
| publisher=Springer Science & Business Media
| isbn=978-0-387-79422-8
| pages=9–10}}</ref><ref>{{cite conference | title=A Logic for Computable Functions with Reflexive and Polymorphic Types |author1=Milner, R. |author2=Morris, L. |author3=Newey, M. | book-title=Proceedings of the Conference on Proving and Improving Programs | year=1975}}</ref> permits writing common [[function (computer science)|functions]] or [[type (computer science)|type]]s that differ only in the set of types on which they operate when used, thus reducing [[duplicate code|duplication]]. Such software entities are known as ''generics'' in [[Ada (programming language)|Ada]], [[C Sharp (programming language)|C#]], [[Delphi (programming language)|Delphi]], [[Eiffel (programming language)|Eiffel]], [[F Sharp (programming language)|F#]], [[Java (programming language)|Java]], [[Nim_(programming_language)|Nim]], [[Python (programming language)|Python]], [[Go (programming language)|Go]], [[Rust (programming language)|Rust]], [[Swift (programming language)|Swift]], [[TypeScript]] and [[Visual Basic .NET]]. They are known as ''[[parametric polymorphism]]'' in [[ML (programming language)|ML]], [[Scala (programming language)|Scala]], [[Julia (programming language)|Julia]], and [[Haskell (programming language)|Haskell]] (the Haskell community also uses the term "generic" for a related but somewhat different concept); ''[[Template (C++)|template]]s'' in [[C++]] and [[D (programming language)|D]]; and ''parameterized types'' in the influential 1994 book ''[[Design Patterns (book)|Design Patterns]]''.<ref name="GoF">
 
Generics was introduced to the main-stream programming with Ada in 1977 and then with ''[[Template (C++)|template]]s'' in [[C++]] it became part of the repertoire of professional library design. The techniques were further improved and ''parameterized types'' were introduced in the influential 1994 book ''[[Design Patterns (book)|Design Patterns]]''.<ref name="GoF">
{{cite book |last1 = Gamma
|first1 = Erich
Line 27 ⟶ 29:
|url-access = registration
|url = https://archive.org/details/designpatternsel00gamm
}}</ref>
 
New techniques were introduced by [[Andrei Alexandrescu]] in his, [[Modern C++ Design|Modern C++ Design: Generic Programming and Design Patterns Applied]] book in 2001. Subsequently [[D (programming language)|D]] implemented the same ideas.
 
Such software entities are known as ''generics'' in [[Ada (programming language)|Ada]], [[C Sharp (programming language)|C#]], [[Delphi (programming language)|Delphi]], [[Eiffel (programming language)|Eiffel]], [[F Sharp (programming language)|F#]], [[Java (programming language)|Java]], [[Nim_(programming_language)|Nim]], [[Python (programming language)|Python]], [[Go (programming language)|Go]], [[Rust (programming language)|Rust]], [[Swift (programming language)|Swift]], [[TypeScript]] and [[Visual Basic .NET]]. They are known as ''[[parametric polymorphism]]'' in [[ML (programming language)|ML]], [[Scala (programming language)|Scala]], [[Julia (programming language)|Julia]], and [[Haskell (programming language)|Haskell]] (the Haskell community also uses the term "generic" for a related but somewhat different concept).
 
 
The term "generic programming" was originally coined by [[David Musser]] and [[Alexander Stepanov]]{{sfn|Musser|Stepanov|1989}} in a more specific sense than the above, to describe a programming paradigm whereby fundamental requirements on types are abstracted from across concrete examples of algorithms and data structures and formalized as [[Concept (generic programming)|concepts]], with [[generic function]]s implemented in terms of these concepts, typically using language genericity mechanisms as described above.