3 ms·
I'm curious how parametric polymorphism got the name generics?
by beastman82 5y ago
I'm curious how parametric polymorphism got the name generics?
- deleted 5y ago[deleted]
- whateveracct 5y agoIt's extra confusing because Haskell has capital-G Generics which are not at all this :)
- recursive 5y agoWhich is totally on-brand for Haskell.
- wk_end 5y agoThis lead me down an interesting path. So, first of all, my (possibly incorrect) understanding is that pure parametric polymorphism doesn't allow you to specify constraints - in Haskell terms, `a -> IO a` is a case of parametric polymorphism, but `Showable a => a -> IO a` or whatever isn't (entirely) - you've got ad hoc polymorphism in there too. So just calling it "parametric polymorphism" would be inaccurate. My assumption was that they took the terminology from Java, but as I looked more into it I started to doubt this. Java called them Generics because the implementation in Java 5 was descended from a research project called "Generic Java". The Generic Java paper [0] uses the term - and the term "Genericity" - freely but doesn't give an original source for it at a glance. They do note that "Modula 3, Ada 95, Eiffel, and Sather" all support them though. Wikipedia has an article on "Generic programming" [1] which notes that "[they] are known as generics in Ada, C#, Delphi, Eiffel, F#, Java, Nim, Python, Go, Rust, Swift, TypeScript and Visual Basic .NET", so this isn't exclusive to Go. It cites a paper from 1989 called "Generic programming" as an origin of the term, although it also claims that "Ada has had generics since it was first designed in 1977–1980", and indeed "generic" is a keyword in Ada 83 [2]. The "Generic programming" paper is written about Ada [3]; my hunch is that Ada's where the term comes from. I'd be curious to see if anyone can find an earlier use of that term. [0] https://homepages.inf.ed.ac.uk/wadler/gj/Documents/gj-oopsla.pdf https://homepages.inf.ed.ac.uk/wadler/gj/Documents/gj-oopsla... [1] https://en.wikipedia.org/wiki/Generic_programming https://en.wikipedia.org/wiki/Generic_programming [2] https://en.wikibooks.org/wiki/Ada_Programming/Ada_83 https://en.wikibooks.org/wiki/Ada_Programming/Ada_83 [3] http://stepanovpapers.com/genprog.pdf http://stepanovpapers.com/genprog.pdf
- cmrdporcupine 5y agoThat the term came from Ada (or the research that went into it) is my understanding, too. It may be associated specifically with Alexander Stepanov [original C++ STL author, but also active in early Ada], or work he did in the early 80s (which contributed to Ada, I believe, and then into C++): http://stepanovpapers.com/ http://stepanovpapers.com/ "David R. Musser, and Alexander A. Stepanov: Tecton: A Language for Manipulating Generic Objects. In Program Specification, Proceedings of a Workshop, Aarhus, Denmark, August 1981" and https://www.oreilly.com/library/view/from-mathematics-to/9780133491791/app01.html https://www.oreilly.com/library/view/from-mathematics-to/978... "Generic Programming. The language Tecton, which first used generic programming concepts, is described in “Tecton: A Language for Manipulating Generic Objects” by Kapur, Musser, and Stepanov (1981). The Ada library is described in the paper “Generic Programming” by Musser and Stepanov (1988), and C++ STL in “The Standard Template Library” by Stepanov and Lee (1994). All of these materials are available on www.stepanovpapers.com." Parametric polymorphism though was present in Standard ML and other functional lanagages from the mid-70s on. But not called generics, and not "generic programming" per se. So, hm.
- Archelaos 5y ago> "David R. Musser, and Alexander A. Stepanov: Tecton: A Language for Manipulating Generic Objects. In Program Specification, Proceedings of a Workshop, Aarhus, Denmark, August 1981" The concept of "generic object" introduced in this paper is quite different from today's: In the proposed framework, a series of refinements constitute a set of design decisions leading to a program. It should be possible to backtrack to any stage of decision making and explore an alternate path of refinements. Different design decisions can thus be compared and evaluated. A notion that seems to be particularly useful for achieving this kind of organization is that of "generic objects." A generic object is a notion for grouping objects sharing common syntactic structure and semantic properties. Informally, a generic object describes a whole class of non-isomorphic possibilities, unless a stage has been reached at which the described objects are fully defined. Adding properties to a generic object makes it more specific by narrowing the range of possibilities. Once we allow such genericity of objects, the way is open also to the development and use of "generic algorithms," which offer a way of organizing and extending our knowledge of algorithms and control. We have begun developing a language called 'Tecton" (Greek for "builder") for constructing generic objects and algorithms.[1] What is called a "generic object" here is what today would rather be called a "base class" of a type hierarchy. [1] Page 402 in http://stepanovpapers.com/Tecton.pdf http://stepanovpapers.com/Tecton.pdf
- bjackman 5y agoSibling comment has some evidence to the contrary but I've always thought of it as a Java marketing term. It lets you write generic classes e.g. "I can write a generic container class that automatically works for any contained type". It's imprecise (you can describe lots of programming language features as enabling "genericity") but I think it makes sense as a descriptive term.
- olliej 5y agoI felt "generics" became the term of industry to contrast to templates, and then if some environment provides generics it is wholesome and good vs nasty template metaprogramming. I also think in that in the context of managed environments .NET was also pushing "generics" terminology (again vs templates) at the same time, and across more languages.
- randomdata 5y agoAs an aside, it is interesting to see Go officially refer to them as generics. For the longest time Pike was overly pedantic about it being parametric polymorphism, not generics.