A style of programming in which algorithms are implemented abstracting from concrete data types. Usually referred to strongly typed languages this term is usually treated as creating software which is minimal in terms of data type requirements and can be instantiated for each conforming data type without changing the callee code.
This tag should be used for questions on applying generic programming techniques. Language specific features (generics, templates) related to issues that are not directly connected with generic programming should not be marked with this tag.
Core ideas of generic programming (GP)
- Lifting of an algorithm stands for finding minimal requirements for a data type interface which allow to implement the algorithm. Usually this improves reusability by widening of range of conforming data types. This process reduces coupling of the software modules and reduces dependence on secondary aspects, which typically leads to cleaner code.
- Specification is a process of constraining data types, typically to facilitate more efficient implementation of an algorithm.
- Concept stands for an interface of a data type which is an object of the lifting and specification processes.
- Reusable, efficient code generally depends on a balance between lifting and specification.
Widely known implementations
- Standard Template Library (STL) which was created by Alexander Stepanov, a GP pioneer.
- Generics in Java and
- Generics in .NET
Although less known, the first relatively widely used programming language to provide direct support for generic programming was Ada 83.