4 ms·
This lead me down an interesting path. So, first of all, my (possibly incorrect) understanding is that pure parametric polymorphism doesn't allow you to specif
by wk_end 5y ago
This 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
- tialaramex 5y agoI think probably you should think of genericity as a style and like say, OOP this style can be supported by language features but you can insist on writing BBC Basic in an OO style, the language just gets in your way all the time. So you could insist on doing generic programming in Go 1.17 say, but it feels very awkward and is slower and anybody reviewing your code is probably going to say "This is the wrong way to use Go" whereas with 1.18 there are more places where this is a reasonable solution. If you hate OOP, you can write a Java program that's just one main function, it will really suck but it isn't impossible. If you hate Functional Programming you could write SML that's all imperatives and again that's going to be possible but the language is fighting you. Parametric Polymorphism isn't a style it's a feature, like Ad Hoc Polymorphism (e.g. C++ function overloading) or Subtype Polymorphism (C++ inheritance) which you could choose to use in your programs or not, but doesn't go away just because you aren't using it.
- donio 5y agoMay not be earlier but this memo about Flavors in Lisp Machine Lisp from 1980 uses the term Generic Operations: https://dspace.mit.edu/handle/1721.1/5700 https://dspace.mit.edu/handle/1721.1/5700 The relevant keyword was called defflavor here, this was later changed to defgeneric in Common Lisp and CLOS.
- zozbot234 5y agoParametric polymorphism w/ constraints would be called "bounded" polymorphism AIUI. The "Generics" term is kinda confusing because it's so generic it doesn't pinpoint the actual programming feature we're working with.
- adonovan 5y agoThe CLU book (Liskov & Guttag, 1986) talks about "parameterized types". Liskov's 1996 essay in History of Programming Languages II describes the feature under the heading "parametric polymorphism". The Modula-3 book (Harbison, 1992) has a chapter (Ch.9, p.163) called "Generics". I suspect this derives from Ada (1983?), which used "generic" as an adjective for all kinds of parameterized constructs, including functions, packages, and types. The first design for generics in Java (Pizza by Odersky & Wadler, 1997) uses the term "parametric polymorphism", which was pretty standard in academia at the time, and originates from Fundamental Concepts in Programming Languages (Strachey, 1967).