github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2010/go_talk-20100121.html (about)

     1  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     2      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     4  <head>
     5  <title>Go, Networked (January 21, 2010)</title>
     6  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     7  <meta name="font-size-adjustment" content="-1" />
     8  <link rel="stylesheet" href="support/slidy.css"
     9    type="text/css" media="screen, projection, print" />
    10  <script src="support/slidy.js" type="text/javascript">
    11  </script>
    12  </head>
    13  <body>
    14  <!-- this defines the slide background -->
    15  
    16  <div class="background">
    17  
    18    <div class="header">
    19    <!-- sized and colored via CSS -->
    20    </div>
    21  
    22    <div class="footer"></div>
    23    </div>
    24  
    25  <div class="slide titlepage">
    26  <div style="height: 135px; width: 480px; overflow: hidden; position: fixed; top: auto; bottom: 10px; left: auto; right: 0;  ">
    27  <img src="support/gordon/bumper480x270.png" style="margin: -135px 0 0 0;"/>
    28  </div>
    29  <br/>
    30  <img src="support/go-logo-white.png">
    31  <br/>
    32  <br/>
    33  <h1 style="padding-right: 0pt; margin-right: 0pt; color: #0066cc; font-size: 250%; border-bottom: 0px;">The Go Programming Language</h1>
    34  <div style="color: #ffcc00;">
    35  <h2>Russ Cox</h2>
    36  <!-- <h3><i>rsc@google.com</i></h3> -->
    37  <br/>
    38  <h3>CNS Winter Research Review<br/><br/>January 21, 2010</h3>
    39  <br/>
    40  <br/>
    41  <!--
    42  <h4><i>click to start; then left/right arrow to change slides</i></h4> -->
    43  </div>
    44  </div>
    45  
    46  <div class="slide">
    47  	<h1>Go</h1>
    48  
    49  	<h2>New</h2>
    50  	<h2>Experimental</h2>
    51  	<h2>Concurrent</h2>
    52  	<h2>Garbage-collected</h2>
    53  	<h2>Systems</h2>
    54  	<h2>Language</h2>
    55  </div>
    56  
    57  <div class="slide">
    58  	<h1>Hello, world</h1>
    59  <pre>
    60  package main
    61  
    62  import "fmt"
    63  
    64  func main() {
    65  	fmt.Printf("Hello, 世界\n")
    66  }
    67  </pre>
    68  </div>
    69  
    70  <div class="slide">
    71  	<h1>History</h1>
    72  	
    73  	<h2>Design started in late 2007.</h2>
    74  	<h2>Implementation starting to work mid-2008.</h2>
    75  	<h2>Released as an open source project in November 2009.</h2>
    76  	<h2>Work continues.</h2>
    77  	<h2>Robert&nbsp;Griesemer, Ken&nbsp;Thompson, Rob&nbsp;Pike, Ian&nbsp;Lance&nbsp;Taylor, Russ&nbsp;Cox, many others</h2>
    78  </div>
    79  
    80  <div class="slide">
    81  	<h1>Goals and Motivation</h1>
    82  	
    83  	<h2>Go fast!</h2>
    84  	<h2>Make programming fun again.</h2>
    85  	<h2>Targeted at systems software, broadly.</h2>
    86  </div>
    87  
    88  <div class="slide">
    89  	<h1>Why isn't programming fun?</h1>
    90  	
    91  	<div class="incremental">
    92  	<h2>Compiled, statically-typed languages (C, C++, Java) require too much typing and too much typing:</h2>
    93  	
    94  	<ul>
    95  		<li>verbose, lots of repetition</li>
    96  		<li>too much focus on type hierarchy</li>
    97  		<li>types get in the way as much as they help</li>
    98  		<li>compiles take far too long</li>
    99  	</ul>
   100  	</div>
   101  	
   102  	<div class="incremental">
   103  	<h2>Dynamic languages (Python, JavaScript) fix these problems (no more types, no more compiler) but introduce others:</h2>
   104  	
   105  	<ul>
   106  		<li>errors at run time that should be caught statically</li>
   107  		<li>no compilation means slow code</li>
   108  	</ul>
   109  	</div>
   110  	
   111  	<h2 class="incremental">Can we combine the best of both?</h2>
   112  </div>
   113  
   114  <div class="slide">
   115  	<h1>Why a new language?</h1>
   116  	
   117  	<div class="incremental">
   118  	<h2>No new systems language in 10+ years.</h2>
   119  	<h2>Current languages designed before ...</h2>
   120  	<h3>... rise of large-scale, networked and multicore computing</h3>
   121  	<h3>... rise of Internet-scale distributed development (many libraries)</h3>
   122  	</div>
   123  </div>
   124  	
   125  <div class="slide">
   126  	<h1>Go</h1>
   127  	
   128  	<h2>Make the language fast.</h2>
   129  	<h2>Make the tools fast.</h2>
   130  </div>
   131  
   132  <div class="slide">
   133  	<h1>Compilation Demo</h1>
   134  	
   135  	<h2>Build all standard Go packages: ~120,000 lines of code.</h2>
   136  </div>
   137  
   138  <div class="slide">
   139  	<h1>Go in one slide</h1>
   140  	
   141  	<h2 class="incremental">Lightweight syntax.</h2>
   142  	
   143  	<h2 class="incremental">Static types: enough to compile well, but inferred much of the time.</h2>
   144  	
   145  	<h2 class="incremental">Methods: on any type, orthogonal to type system.</h2>
   146  	
   147  	<h2 class="incremental">Abstract types: interface values, relations inferred statically.</h2>
   148  	
   149  	<h2 class="incremental">Visibility: inferred from case of name.</h2>
   150  
   151  	<h2 class="incremental">First-class functions.</h2>
   152  	
   153  	<h2 class="incremental">Garbage collection.</h2>
   154  
   155  	<br/>
   156  	
   157  	<h2 class="incremental">Lightweight feel of a scripting language but compiled.</h2>
   158  </div>
   159  
   160  <div class="slide">
   161  	<h1>Go, concurrently</h1>
   162  	
   163  	<h2>Cheap to create a new flow of control (goroutine):</h2>
   164  	
   165  <pre>
   166  func main() {
   167  	go expensiveComputation(x, y, z)
   168  	anotherExpensiveComputation(a, b, c)
   169  }
   170  </pre>
   171  
   172  	<h2>Two expensive computations in parallel.</h2>
   173  </div>
   174  
   175  <div class="slide">
   176  	<h1>Go, concurrently</h1>
   177  	
   178  	<h2>Cheap to create a new flow of control (goroutine):</h2>
   179  	
   180  <pre>
   181  	for {
   182  		rw := l.Accept()
   183  		conn := newConn(rw, handler)
   184  		go conn.serve()
   185  	}
   186  </pre>
   187  
   188  	<h2>Concurrent web server.</h2>
   189  	<h2>Network connections multiplexed onto epoll.</h2>
   190  		<ul>
   191  		<li>many blocked Read calls != many blocked OS threads</li>
   192  		</ul>
   193  
   194  </div>
   195  
   196  <div class="slide">
   197  	<h1>Go, synchronized</h1>
   198  	
   199  	<h2>Use explicit messages to communicate and synchronize.</h2>
   200  	
   201  <pre>
   202  func computeAndSend(ch chan int, x, y, z int) {
   203  	ch <- expensiveComputation(x, y, z)
   204  }
   205  
   206  func main() {
   207  	ch := make(chan int)
   208  	go computeAndSend(ch, x, y, z)
   209  	v2 := anotherExpensiveComputation(a, b, c)
   210  	v1 := <-ch
   211  	fmt.Println(v1, v2)
   212  }
   213  </pre>
   214  	<h2>Notice communication of result in addition to synchronization.</h2>
   215  </div>
   216  
   217  <div class="slide">
   218  	<h1>Go, synchronized</h1>
   219  	
   220  	<h2>RPC client</h2>
   221  
   222  <pre>
   223  func (client *Client) Call(method string, args, reply interface{}) os.Error {
   224      // Send RPC message.
   225      call := client.Go(method, args, reply, nil)
   226  	
   227      // Read reply from Done channel.
   228      <-call.Done
   229  
   230      return call.Error
   231  }
   232  </pre>	
   233  </div>
   234  
   235  <div class="slide">
   236  	<h1>Go, synchronized</h1>
   237  	
   238  	<h2>RPC client demux</h2>
   239  
   240  <pre>
   241  func (client *Client) input() {
   242  	for {
   243  		resp := client.readResponse()
   244  		client.mutex.Lock()
   245  		c := client.pending[resp.Seq]
   246  		client.pending[resp.Seq] = c, false
   247  		client.mutex.Unlock()
   248  		if resp.Error != "" {
   249  			c.Error = os.ErrorString(resp.error)
   250  		}
   251  		resp.Decode(c.Reply)
   252  		c.Done <- c
   253  	}
   254  }
   255  </pre>
   256  </div>
   257  
   258  <div class="slide">
   259  	<h1>Go, synchronized</h1>
   260  	
   261  	<h2>RPC client demux</h2>
   262  
   263  <pre>
   264  func (client *Client) input() {
   265  	for {
   266  		<font style="color: black;">resp := client.readResponse()</font>
   267  		client.mutex.Lock()
   268  		c := client.pending[resp.Seq]
   269  		client.pending[resp.Seq] = c, false
   270  		client.mutex.Unlock()
   271  		if resp.Error != "" {
   272  			c.Error = os.ErrorString(resp.error)
   273  		}
   274  		resp.Decode(c.Reply)
   275  		c.Done <- c
   276  	}
   277  }
   278  </pre>
   279  <h2>Read response from network.</h2>
   280  </div>
   281  
   282  <div class="slide">
   283  	<h1>Go, synchronized</h1>
   284  	
   285  	<h2>RPC client demux</h2>
   286  
   287  <pre>
   288  func (client *Client) input() {
   289  	for {
   290  		resp := client.readResponse()
   291  		<font style="color: black;">client.mutex.Lock()
   292  		c := client.pending[resp.Seq]
   293  		client.pending[resp.Seq] = c, false
   294  		client.mutex.Unlock()</font>
   295  		if resp.Error != "" {
   296  			c.Error = os.ErrorString(resp.error)
   297  		}
   298  		resp.Decode(c.Reply)
   299  		c.Done <- c
   300  	}
   301  }
   302  </pre>
   303  <h2>Look up request by sequence number.</h2>
   304  </div>
   305  
   306  <div class="slide">
   307  	<h1>Go, synchronized</h1>
   308  	
   309  	<h2>RPC client demux</h2>
   310  
   311  <pre>
   312  func (client *Client) input() {
   313  	for {
   314  		resp := client.readResponse()
   315  		client.mutex.Lock()
   316  		c := client.pending[resp.Seq]
   317  		client.pending[resp.Seq] = c, false
   318  		client.mutex.Unlock()
   319  		<font style="color: black;">if resp.Error != "" {
   320  			c.Error = os.ErrorString(resp.error)
   321  		}
   322  		resp.Decode(c.Reply)</font>
   323  		c.Done <- c
   324  	}
   325  }
   326  </pre>
   327  <h2>Decode response fields from payload.</h2>
   328  </div>
   329  
   330  <div class="slide">
   331  	<h1>Go, synchronized</h1>
   332  	
   333  	<h2>RPC client demux</h2>
   334  
   335  <pre>
   336  func (client *Client) input() {
   337  	for {
   338  		resp := client.readResponse()
   339  		client.mutex.Lock()
   340  		c := client.pending[resp.Seq]
   341  		client.pending[resp.Seq] = c, false
   342  		client.mutex.Unlock()
   343  		if resp.Error != "" {
   344  			c.Error = os.ErrorString(resp.error)
   345  		}
   346  		resp.Decode(c.Reply)
   347  		<font style="color: black;">c.Done <- c</font>
   348  	}
   349  }
   350  </pre>
   351  <h2>Tell client that it finished.</h2>
   352  </div>
   353  
   354  <div class="slide">
   355  	<h1>Go, synchronized</h1>
   356  	
   357  	<h2>RPC client demux</h2>
   358  
   359  <pre>
   360  func (client *Client) input() {
   361  	for {
   362  		resp := client.readResponse()
   363  		client.mutex.Lock()
   364  		c := client.pending[resp.Seq]
   365  		client.pending[resp.Seq] = c, false
   366  		client.mutex.Unlock()
   367  		if resp.Error != "" {
   368  			c.Error = os.ErrorString(resp.error)
   369  		}
   370  		resp.Decode(c.Reply)
   371  		c.Done <- c
   372  	}
   373  }
   374  </pre>
   375  
   376  <h2>Can create multiple Calls with same Done channel
   377  and distinguish which finished by inspecting value sent on channel.
   378  </h2>
   379  
   380  </div>
   381  
   382  <div class="slide">
   383  	<h1>Goroutine demo</h1>
   384  	
   385  	<h2>Chain together 100,000 goroutines connected by 100,001 channels.</h2>
   386  	
   387  	<h2>Send a value to one end of the chain.</h2>
   388  	
   389  	<h2>Each passes it along, increments.</h2>
   390  	
   391  	<h2>Receive value out the other end of the chain.</h2>
   392  </div>
   393  	
   394  
   395  <div class="slide">
   396  	<h1>Go Status</h1>
   397  </div>
   398  
   399  <div class="slide">
   400  	<h1>Go Status</h1>
   401  	
   402  	<h2>Open source:</h2>
   403  	<ul>
   404  	<li>released on November 10, 2009
   405  	<li>regular releases (~ weekly)
   406  	<li>all development done in public Mercurial repository
   407  	<li>outside contributions welcome
   408  	<li>two independent compiler implementations
   409  	<li>XML, JSON, HTTP, TLS/SSL, native RPC, (network channels,) ...
   410  	</ul>
   411  </div>
   412  
   413  <div class="slide">
   414  	<h1>Go Status</h1>
   415  	
   416  	<h2>Open source</h2>
   417  
   418  	<h2>Portable:</h2>
   419  	<ul>
   420  	<li>FreeBSD, Linux, OS X (x86, x86-64)
   421  	<li>(in progress) Linux arm, Native Client x86, Windows x86.
   422  	</ul>
   423  </div>
   424  
   425  <div class="slide">
   426  	<h1>Go Status</h1>
   427  	
   428  	<h2>Open source</h2>
   429  	<h2>Portable</h2>
   430  
   431  	<h2>Still in progress, experimental.  Yet to come:</h2>
   432  	<ul>
   433  	<li>production garbage collector
   434  	<li>generics?
   435  	<li>exceptions?
   436  	<li>unions or sum types?
   437  	</ul>
   438  </div>
   439  
   440  <div class="slide titlepage">
   441  	<h1>Questions?</h1>
   442  	<br><br>
   443  	<center>
   444  	<img src="support/bumper640x360.png">
   445  	</center>
   446  	<br><br>
   447  	<div style="color: #ffcc00;">
   448  	<!-- <h3><i>rsc@google.com</i></h3> -->
   449  	</div>
   450  </div>
   451  
   452  </body></html>