30
Hello, Go Sun Kai

Hello, Gohome3k.cn-bj.ufileos.com/golang.pdf · 2019. 4. 29. · • 语结构决定 思维和为 • 萨丕尔-沃夫假说 • 7000个语的平宇宙 • 编程语?

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • Hello, GoSun Kai

  • • 语⾔言结构决定思维和⾏行行为

    • 萨丕尔-沃夫假说

    • 7000个语⾔言的平⾏行行宇宙

    • 编程语⾔言?

  • • 埃拉托斯特尼筛法 sieve of Eratosthenes

  • #include #include #include #include using namespace std;bool f[1000005];int main(){ int n; scanf("%d",&n); f[1]=false; for(int i=2;i

  • Gofunc generate(ch chan

  • • 编程语⾔言决定编程思维

    • 设计哲学/价值观决定编程语⾔言

    ⾏行行为价值观

    思维

    结构

  • 说说Go语⾔言

  • Go语⾔言

    • Robert Griesemer, Rob Pike, Ken Thompson

    • Ian Lance Taylor, Russ Cox

  • • 2007

    • 2009

    • 2012

  • 诞⽣生背景

    • 解决Google的问题

    • ⼤大硬件

    • ⼤大软件

    • 新硬件

  • Go的价值观

    • 简单

    • 正交

    • 并发

    • 安全

    Unix设计哲学

    Go fast! Make programming fun again

  • 简单-语法• 25个keyword

    • 短命名

    • 简单写法

    • ⼀一种循环 for

    • ⼀一种constants

    • Error机制

  • 简单-类型

    • 静态类型

    var i int := 1 var s string greeting := "Hello, Bootcamp!" mul := func(x, y int) int { return x * y } var arr [3]int = [3]int{1, 3, 4} var s []int = []int{1, 3, 4} p := &i

    counts := make(map[string]int)

    type Point struct { X, Y float64 }

    func (p *Point) Abs() float64 { return math.Sqrt(p.X*p.X + p.Y*p.Y) }

  • 简单-⼯工具

    • gogc

    • gofmt

    • goimports

    • godoc

  • 正交

    • 正交性

    • 组合

  • 正交

    • 正交性

    • ⽆无类型体系,类型定义正交独⽴立

    • ⽅方法和类型正交

    • interface和实现正交

  • 正交

    • 组合

    • OOP

    • OOP 对我只代表消息、局部持有和保护、状态处理理的隐藏,以及对所有事物尽可能的延后绑定。 —Alay Kay

    • - 继承

    • - 多态

  • 正交

    • 组合

    • 类型嵌⼊入

    • interface

    • 实现OOP所有功能

    • 包括多态

    type ReadWriter struct { Reader Writer }type Handler interface { Serve(Request *request) }

    type Any interface {}

  • 并发

    • CSP (Communicating Sequential Processes)

    • Actor

    • Thread

  • Goroutines

    • Go runtime调度的基本单元

    • channels

    • select

  • Goroutines

    • go fetch()

    • make(chan int)

    • select

  • 安全

    • GC

    • 并发安全

    • 语法层⾯面

  • 其他

    • 构建速度

    • 包模型

  • Go Runtime

    • 内存分配

    • 垃圾收集

    • Goroutine调度器器

  • Go Runtime• 内存分配

    • TCMalloc

  • Go Runtime

    • 垃圾收集

    • 阈值检查

    • 强制回收

  • Go Runtime• Goroutine调度器器

    • MAXTHREADS

    • MAXPROCS

  • Go Runtime• Goroutine调度器器

  • Go Runtime• Goroutine调度器器

    • newproc

  • 推荐

    • Go语⾔言圣经

    • ⾬雨痕的语⾔言笔记

    • Go Talk