Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Generic programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Style of computer programming}} {{Use dmy dates|date=November 2020}} {{Distinguish|Genetic programming|Pseudocode}} '''Generic programming''' is a style of [[computer programming]] in which [[algorithm]]s are written in terms of [[data type]]s ''to-be-specified-later'' that are then ''instantiated'' when needed for specific types provided as [[Parameter (computer programming)|parameters]]. This approach, pioneered in the [[programming language]] [[ML (programming language)|ML]] in 1973,<ref name="Lee2008"> {{cite book | last1=Lee | first1=Kent D. | date=15 December 2008 | title=Programming Languages: An Active Learning Approach | url=https://books.google.com/books?id=OuW5dC2O99AC&pg=PA9 | publisher=Springer Science & Business Media | isbn=978-0-387-79422-8 | pages=9β10}}</ref><ref>{{cite conference |last1=Milner |first1=R. |author1-link=Robin Milner |last2=Morris |first2=L. |last3=Newey |first3=M. |year=1975 |title=A Logic for Computable Functions with Reflexive and Polymorphic Types |book-title=Proceedings of the Conference on Proving and Improving Programs}}</ref> permits writing common [[Function (computer science)|functions]] or [[data type]]s that differ only in the [[Set (mathematics)|set]] of types on which they operate when used, thus reducing [[duplicate code]]. Generic programming was introduced to the mainstream with [[Ada (programming language)|Ada]] in 1977. With [[Template (C++)|templates]] in [[C++]], generic programming became part of the repertoire of professional [[Library (computing)|library]] design. The techniques were further improved and ''parameterized types'' were introduced in the influential 1994 book ''[[Design Patterns]]''.<ref name="GoF"> {{cite book |last1=Gamma |first1=Erich |last2=Helm |first2=Richard |last3=Johnson |first3=Ralph |last4=Vlissides |first4=John |date=1994 |title=Design Patterns |publisher=Addison-Wesley |isbn=0-201-63361-2 |url-access=registration |url=https://archive.org/details/designpatternsel00gamm }}</ref> New techniques were introduced by [[Andrei Alexandrescu]] in his 2001 book ''[[Modern C++ Design]]: Generic Programming and Design Patterns Applied''. 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 (software)|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]]. (Haskell terminology 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 in which fundamental requirements on data types are abstracted from across concrete examples of algorithms and [[data structure]]s 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)