Ready, Set, GO! Chad McCallum ASP.NET MVP iQmetrix Software www.rtigger.com - @ChadEmm An Introduction to the Go Programming Language
What is Go?  A programming language!  Initially created as a Google 20% project  Released as an open source project on November 10th, 2009  Go 1 (version 1) released on March 28th, 2012
The Software Development Landscape  Born out of frustration with current languages  There was a choice between efficient compilation, efficient execution, or ease of programming – most languages didn’t offer all three  Computers are faster, but software development isn’t  Dependency management is an unnecessarily large, complex part of software development  The complexity and awkwardness of type systems are losing out to languages like Python and JavaScript  Old languages haven’t caught up to modern affordances, like garbage collection and parallel computation  Multicore programming is scary and worrysome
Enter Go  Possible to compile a large program in a few seconds on a single computer  Provides a dependency model that avoids the overhead of traditional systems  The type system has no hierarchy, so no time is lost defining relationships  Fully garbage collected and provides primitives for concurrent execution and communication  By design, offers an approach to system software on multicore machines
A Review of Go’s Features  Simple language specification  Compiles statically linked binaries without external dependencies  Remote package management  Concurrency primitives
Simple Language Specification  “Language specification simple enough to keep in a programmer’s head”  No type inheritance (uses duck typing)  No method or operator overloading  No pointer math  No assertions  No generic programming
Statically Linked Binaries  Compiles to native machine code (x86 and ARM)  All referenced libraries are compiled into the same binary – no need to install libraries or framework on target machine  Because there’s no intermediate language, interpreter, or framework, applications start and run with minimal overhead
Remote Package Management  Can import dependencies directly from remote repositories, like GitHub, BitBucket, Google Code  go get github.com/ChadMcCallum/gotest  Uses the current version of the code in “master” (git) or “default” (mercurial)  Downloaded to local GOPATH folder
Concurrency Primitives  goroutine – executes function on a lightweight process  Similar to task pools in .NET, functions are executed on any available thread allocated by the application  Ensures routines don’t block each other  Allows developers to write synchronous code while being fully non- blocking  Channels provide a way to read and write between routines without managing synchronization  A routine that writes to a channel will wait until its message is received  A routine that reads from a channel will wait until it receives a message
Why Choose Go?  Why choose any language?  Popularity – is there a decent amount of community support?  Language-domain match – is the strengths of the language geared towards your problem domain?  Libraries – what packages already exist that you can reuse?  Efficiency – does the compiler and execution match up with your project’s requirements?  Tools – do the appropriate coding, debugging, tracing, and testing tools exist?
Popularity  Currently 36th on the TIOBE Index (March 2014)  Used in a number of large projects at Google  Youtube.com, dl.google.com, Google App Engine  Used in a number of production systems  Bit.ly, Torbit, pool.ntp.org, Canonical, CloudFlare, Conformal, Nov artis, BBC, SoundCloud, Moovweb, Heroku, Nokia  4472 questions in StackOverflow  16681 topics on the golang-nuts group
Language-Domain Match  Targeted at systems programming  Strengths in concurrency and deployment model  Mostly used in server and message-processing scenarios  Can, and does, support other scenarios  Web apps, games, graphical tools, education
Libraries  25,522 repositories on GitHub  Application containers,  web frameworks,  websockets,  continuous integration,  shared key-value stores,  shared cache,  distributed messaging,  maching imaging,  SQL engines,  service orchestration,  client code generation,  analytics,  autocomplete,  load testing,  http traffic capture,  static site generation,  geolocation,  PaaS
Efficiency  Natively compiled binaries  Not interpreted  No external dependencies  No Intermediate Language, Common Language Runtime, or Virtual Machine  Calculating 8 primes in parallel .NET Tasks – 12.6 seconds Goroutines – 5.99 seconds
Tools  go build – compiles packages and dependencies into executable  go fix – rewrites programs that use old APIs to use the newest version  go fmt – changes source code to match go standard  go get – download and install packages and dependencies  go install – compile and install packages and dependencies  go run – compile and run program  go test – run tests in packages
IDEs  LiteIDE – cross-platform IDE with support for Go and Markdown  Go plugin for Eclipse (Goclipse) – plugin for Eclipse  Zeus – Windows-only IDE with Go support  All three offer debugging, syntax highlighting, and code completion
Ready, Set, GO!  golang.org  tour.golang.org  play.golang.org  godoc.org  gobyexample.com  goinggo.net Chad McCallum @ChadEmm www.rtigger.com

Ready, set, go! An introduction to the Go programming language

  • 1.
    Ready, Set, GO! ChadMcCallum ASP.NET MVP iQmetrix Software www.rtigger.com - @ChadEmm An Introduction to the Go Programming Language
  • 2.
    What is Go? A programming language!  Initially created as a Google 20% project  Released as an open source project on November 10th, 2009  Go 1 (version 1) released on March 28th, 2012
  • 3.
    The Software DevelopmentLandscape  Born out of frustration with current languages  There was a choice between efficient compilation, efficient execution, or ease of programming – most languages didn’t offer all three  Computers are faster, but software development isn’t  Dependency management is an unnecessarily large, complex part of software development  The complexity and awkwardness of type systems are losing out to languages like Python and JavaScript  Old languages haven’t caught up to modern affordances, like garbage collection and parallel computation  Multicore programming is scary and worrysome
  • 4.
    Enter Go  Possibleto compile a large program in a few seconds on a single computer  Provides a dependency model that avoids the overhead of traditional systems  The type system has no hierarchy, so no time is lost defining relationships  Fully garbage collected and provides primitives for concurrent execution and communication  By design, offers an approach to system software on multicore machines
  • 5.
    A Review ofGo’s Features  Simple language specification  Compiles statically linked binaries without external dependencies  Remote package management  Concurrency primitives
  • 6.
    Simple Language Specification “Language specification simple enough to keep in a programmer’s head”  No type inheritance (uses duck typing)  No method or operator overloading  No pointer math  No assertions  No generic programming
  • 7.
    Statically Linked Binaries Compiles to native machine code (x86 and ARM)  All referenced libraries are compiled into the same binary – no need to install libraries or framework on target machine  Because there’s no intermediate language, interpreter, or framework, applications start and run with minimal overhead
  • 8.
    Remote Package Management Can import dependencies directly from remote repositories, like GitHub, BitBucket, Google Code  go get github.com/ChadMcCallum/gotest  Uses the current version of the code in “master” (git) or “default” (mercurial)  Downloaded to local GOPATH folder
  • 9.
    Concurrency Primitives  goroutine– executes function on a lightweight process  Similar to task pools in .NET, functions are executed on any available thread allocated by the application  Ensures routines don’t block each other  Allows developers to write synchronous code while being fully non- blocking  Channels provide a way to read and write between routines without managing synchronization  A routine that writes to a channel will wait until its message is received  A routine that reads from a channel will wait until it receives a message
  • 10.
    Why Choose Go? Why choose any language?  Popularity – is there a decent amount of community support?  Language-domain match – is the strengths of the language geared towards your problem domain?  Libraries – what packages already exist that you can reuse?  Efficiency – does the compiler and execution match up with your project’s requirements?  Tools – do the appropriate coding, debugging, tracing, and testing tools exist?
  • 11.
    Popularity  Currently 36thon the TIOBE Index (March 2014)  Used in a number of large projects at Google  Youtube.com, dl.google.com, Google App Engine  Used in a number of production systems  Bit.ly, Torbit, pool.ntp.org, Canonical, CloudFlare, Conformal, Nov artis, BBC, SoundCloud, Moovweb, Heroku, Nokia  4472 questions in StackOverflow  16681 topics on the golang-nuts group
  • 12.
    Language-Domain Match  Targetedat systems programming  Strengths in concurrency and deployment model  Mostly used in server and message-processing scenarios  Can, and does, support other scenarios  Web apps, games, graphical tools, education
  • 13.
    Libraries  25,522 repositorieson GitHub  Application containers,  web frameworks,  websockets,  continuous integration,  shared key-value stores,  shared cache,  distributed messaging,  maching imaging,  SQL engines,  service orchestration,  client code generation,  analytics,  autocomplete,  load testing,  http traffic capture,  static site generation,  geolocation,  PaaS
  • 14.
    Efficiency  Natively compiledbinaries  Not interpreted  No external dependencies  No Intermediate Language, Common Language Runtime, or Virtual Machine  Calculating 8 primes in parallel .NET Tasks – 12.6 seconds Goroutines – 5.99 seconds
  • 15.
    Tools  go build– compiles packages and dependencies into executable  go fix – rewrites programs that use old APIs to use the newest version  go fmt – changes source code to match go standard  go get – download and install packages and dependencies  go install – compile and install packages and dependencies  go run – compile and run program  go test – run tests in packages
  • 16.
    IDEs  LiteIDE –cross-platform IDE with support for Go and Markdown  Go plugin for Eclipse (Goclipse) – plugin for Eclipse  Zeus – Windows-only IDE with Go support  All three offer debugging, syntax highlighting, and code completion
  • 17.
    Ready, Set, GO! golang.org  tour.golang.org  play.golang.org  godoc.org  gobyexample.com  goinggo.net Chad McCallum @ChadEmm www.rtigger.com

Editor's Notes

  • #8 Do a demo compile of a go app hereGo build car.go
  • #9 Download a package and show compiled resultGo get github.com/mitchellh/multistepBrowse to d:\go\pkg\...
  • #10 Show code for channels.go, execute
  • #12 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
  • #14 https://github.com/search?o=desc&q=language%3Ago&s=stars&type=Repositories
  • #15 Show source code for .net and go. Execute, show result