Listen

Description

# 第 8 期:泛型来了!

录制时间: 2022-05-06

- 嘉宾:[老貘](https://gfw.tapirgames.com/)

- 主持:[杨文](https://maiyang.me),[欧长坤](https://changkun.de)

本期摘要:这是 Go 夜聊的第八期节目,我们和 Go 语言 101 的作者一起聊了聊期待已久的泛型,我们聊到了为什么需要泛型,设计的优点、讨论时的期望与正式发布时的失望。新出现的类型集是什么?comparable 又是什么?目前的泛型设计在未来还有多大的改进空间?

## 时间线

- 00:12 开场

- 01:10 接触 Go 语言的动机

- 03:30 编写《Go 101》的原因

- 04:42 活跃在 Go 语言社区

- 09:27 独立游戏的行业经历

- 12:11 用 Go 语言做游戏

- 13:51 泛型产生的动机,与 Go Generate 的对比

- 20:21 接口、类型集、类型约束的关系

- 28:36 类型集与泛型的关系

- 30:40 接口与类型集是同一个概念吗?

- 31:34 comparable 类型、它能解决什么问题、它还有哪些争议

- 37:42 接口作为值类型

- 42:45 泛型设计的其他优点

- 48:10 泛型设计的缺点

- 58:09 泛型设计的限制

- 66:09 对泛型未来的期望与失望

- 68:20 Go 团队排外吗?

- 71:35 Go 语言 101 背后的故事

- 83:38 结尾推荐

- 87:55 尾声

## 相关链接

- [老貘的主页](https://gfw.tapirgames.com/)

- [Go 语言 101](https://go101.org/)

- [Go 泛型 101](https://go101.org/generics/101.html)

- [泛型的官方上手教程](https://go.dev/doc/tutorial/generics)

- [观点:类型集和接口不等价](https://go-review.googlesource.com/c/go/+/401874)

- [spec: document definition of comparable](https://go.dev/issue/50646)

- [spec: any no longer implements comparable](https://go.dev/issue/51257)

- [proposal: spec: permit values to have type "comparable"](https://go.dev/issue/51338)

- [proposal: spec: permit non-interface types that support == to satisfy the comparable constraint](https://go.dev/issue/52474)

- [proposal: spec: allow interface types to instantiate comparable type parameters](https://go.dev/issue/52509)

- [proposal: spec: add new constraint kind satisfied by types that support == (including interface types)](https://go.dev/issue/52531)

- [proposal: type parameters are comparable unless they exclude comparable types](https://go.dev/issue/52614)

- [proposal: the comparable interface represents the comparable subset of run-time values](https://go.dev/issue/52624)

- [how to update APIs for generics](https://go.dev/issue/48287)

- [proposal: spec: allow type parameters in methods](https://go.dev/issue/49085)

- [追风筝的人](https://book.douban.com/subject/1770782/)

- [灿烂千阳](https://book.douban.com/subject/2143732/)

- [群山回唱](https://book.douban.com/subject/24845582/)

- [理解自由意志](https://book.douban.com/subject/3206314/)

- [AI 新生](https://book.douban.com/subject/35149258/)