Friday, October 28, 2016

Generic Programming

Generic programming is defined in Musser & Stepanov (1989) as follows,
Generic programming centers around the idea of abstracting from concrete, efficient algorithms to obtain generic algorithms that can be combined with different data representations to produce a wide variety of useful software.
— Musser, David R.; Stepanov, Alexander A., Generic Programming
or, more simply put,

[Generic programming is the process of lifting] algorithms and data structures from concrete examples to their most general and abstract form.
— Bjarne Stroustrup, Evolving a language in and for the real world: C++ 1991-2006
This is achieved by writing algorithms in terms of "types to-be-specified-later".
Generic programming is a characteristic of computer science in general, as opposed to a characteristic of a specific programming language. It deals with algorithms, and can be applied to most languages, with some differences. For example, these "types to-be-specified-later" are called generics in languages such as Java, C#, F#, Objective-C, and Swift; parametric polymorphism in ones such as ML, Scala, Haskell; and templates in languages like C++ and D;
Each language also has its own way of treating these types, with whatever advantages and disadvantages those ways may entail (there is no such thing as perfection).
Below are some more details about, and an example of Generic Programming.



 
References:
https://en.wikipedia.org/wiki/Generic_programming#Generics_in_Java
Image References:
Image 1: https://www.google.com/imgres?imgurl=http%3A%2F%2Fimages.slideplayer.com%2F16%2F5079496%2Fslides%2Fslide_1.jpg&imgrefurl=http%3A%2F%2Fslideplayer.com%2Fslide%2F5079496%2F&docid=9BEYxVSEtYQM1M&tbnid=qlXd3qo9VaSJEM%3A&w=960&h=720&noj=1&bih=875&biw=1637&ved=0ahUKEwjo7Na0qP7PAhUEOyYKHRHvAPcQMwhcKDMwMw&iact=mrc&uact=8
Image 2: https://www.google.com/imgres?imgurl=http%3A%2F%2Fimages.locanto.in%2F1195428230%2FLearn-use-of-Generic-Programming-in-Java-5_5.jpg&imgrefurl=http%3A%2F%2Fghaziabad.locanto.in%2FID_497963856%2FLearn-use-of-Generic-Programming-in-Java-5.html&docid=kKEqqPItgOTJwM&tbnid=Ov6i86DzN9gOJM%3A&w=283&h=178&noj=1&bih=875&biw=1637&ved=0ahUKEwjo7Na0qP7PAhUEOyYKHRHvAPcQMwhgKDcwNw&iact=mrc&uact=8

No comments:

Post a Comment