Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: The feature currently called "Generics" should be called "Parametric Polymorphism" #40537

Closed
ayang64 opened this issue Aug 3, 2020 · 8 comments
Milestone

Comments

@ayang64
Copy link
Contributor

@ayang64 ayang64 commented Aug 3, 2020

I feel like "generics" isn't a very well defined term and the feature that Go is adding is precisely parametric polymorphism.

  • I've heard the argument that "generics" is an easier term for users to grasp but I think the term's fuzziness and lack of precision actually make it more difficult to talk about. For example, try googling for "generics" to understand the new feature. Then google "parametric polymorphism" and I think you'll find a clearer description. On wikipedia, you can find articles for "generic programming" and "generic function" but neither quite describe the proposed feature. More importanly, I don't think you can find an article for "generics" at all.
  • I think it is more precise to talk about the feature as "parametric polymorphism" and describe what you can do with it as "generic programming". That makes a clear distinction between the language feature itself and what it allows.
  • Parametric polymorphism encompasses the concept of static type safety -- which, again, make it better suited to describe what we're now calling "generics".

I propose that the Go project start rephrasing what we call "generics" as "parametric polymorphism" to more clearly and precisely describe the upcoming feature. This includes changing the verbiage in the proposal, future blog posts, commit messages, etc.

I think Go has done an excellent job at the "naming of things" part of software development. I think this is an opportunity to get the naming of this feature right.

@robpike
Copy link
Contributor

@robpike robpike commented Aug 3, 2020

I completely agree with what you say but fear that the "generics" word, from Java, has become the generic term for the general concept.

@ayang64
Copy link
Contributor Author

@ayang64 ayang64 commented Aug 3, 2020

@robpike -- I understand but I don't think we should get this wrong just because Java has (if Java jumps off of a bridge...). I feel like there was a lot of confusion about what exactly this new feature entails and I think naming it correctly could help users understand it without having to wade through the murky terminology.

@ayang64 ayang64 changed the title The feature currently called "Generics" should be called "Parametric Polymorphism" proposal: The feature currently called "Generics" should be called "Parametric Polymorphism" Aug 3, 2020
@gopherbot gopherbot added this to the Proposal milestone Aug 3, 2020
@gopherbot gopherbot added the Proposal label Aug 3, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 3, 2020

I called it parametric polymorphism for a while, but many people just didn't understand what I was talking about. Also, although I think the version in the design draft is parametric polymorphism, it is not the same as some other languages that use the term parameteric polymorphism, because the Go type parameters are bounded by something that is similar to a subtyping relationship but actually isn't one (at least not according to the Go type rules). See also https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#background.

Anybody who wants to should go right ahead and call it parametric polymorphism. But I don't think we would get any benefit from doing so in general.

@ulikunitz
Copy link
Contributor

@ulikunitz ulikunitz commented Aug 3, 2020

While Java definitely established the term generics for today's programmer generation, the term is actually older.

The programming language Ada had a "generic" keyword since at least 1983 if not 1978. (The Internet appears to have only the 1983 language specification.) The 1989 paper "Generic Programming" by Musser and Stepanov uses the term generics and is based on the experience developing the Ada Generic Library. Stepanov later developed the Standard Template Library (STL) for C++.

Research into the concept predates Ada. Milner, who led the development of the ML language, published the paper "A Theory of Type Polymorphism in Programming" in 1978. The abstract mentions that the concept has already been implemented for ML.

@ayang64
Copy link
Contributor Author

@ayang64 ayang64 commented Aug 3, 2020

@ulikunitz -- sure, the notion of generic programming has been around for a while. What I have issue with is the term "generics". So yes, as a keyword, generic has been around. As a concept, "generic programming" has been around. But I think the use of the term "generics" to describe both the features that enable generic programming and the practice of generic programming to be a Javaism -- and I don't think that is a good thing.

I think this is a subtle but important point -- though I'm sure I'm missing out on some history so I'm definitely here to be educated.

Again, my point is: the term "generics" isn't well defined, is difficult to "google" for or find as a term-of-art. Therefore, I think it is a bad name for the feature that is being added.

We should call it what it is: Parametric Polymorphism (maybe with Bounds). The name is self descriptive -- if it seems a little dense, simply looking up the definition of each word should make the intention of the feature clear:

Parametric: having to do with parameters
Polymorphism: able to take multiple shapes

Again, I think that is a good way to talk about he upcoming feature and we can still talk about what it allows which is generic programming in the sense that you describe.

@ayang64
Copy link
Contributor Author

@ayang64 ayang64 commented Aug 3, 2020

I feel like "the train has left the station" on this. I was hoping to appeal to have this semantic issue cleared up before the term "generics" gets further entrenched.

I'm also open to simply being wrong. I figure this is what the proposal process is for -- to vet ideas like this.

@ayang64
Copy link
Contributor Author

@ayang64 ayang64 commented Aug 3, 2020

@ulikunitz -- the term "generics" is used only once in the "Generic Programming" paper by Musser and Stepanov but not in the same way as we're talking about them -- it seems to be referring to Ada functions that are declared as generic.

So for Ada, the use of the term "generics" seems to be tied to the syntax. To my knowledge, Go isn't adding a generic keyword.

Finally, even this wikibook on Ada generics starts by talking about PP first:

https://en.wikibooks.org/wiki/Ada_Programming/Generics

@bradfitz bradfitz added the generics label Aug 5, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 7, 2020

I'm going to close this issue. Sorry. This battle has been lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.