logoalt Hacker News

win311fwgtoday at 2:05 AM1 replyview on HN

Generics were always planned, of course: https://www.youtube.com/watch?v=rKnDgT73v8s&t=3267s

Rejecting templates does not mean rejecting generics.


Replies

AdieuToLogictoday at 3:05 AM

> Generics were always planned, of course ...

This is provably incorrect.

The position held for many years by the language authors was[0]:

  Generics may well be added at some point. We don't feel an 
  urgency for them, although we understand some programmers 
  do.
  
  Generics are convenient but they come at a cost in 
  complexity in the type system and run-time. We haven't yet 
  found a design that gives value proportionate to the 
  complexity, although we continue to think about it. 
  Meanwhile, Go's built-in maps and slices, plus the ability 
  to use the empty interface to construct containers (with 
  explicit unboxing) mean in many cases it is possible to 
  write code that does what generics would enable, if less 
  smoothly. 
Once the community could no longer be held back, the golang FAQ presented a very different position[1]:

  The Go 1.18 release added type parameters to the language. 
  This permits a form of polymorphic or generic programming.
0 - https://web.archive.org/web/20170102202940/http://golang.org...

1 - https://go.dev/doc/faq#generics

show 3 replies