SlideShare a Scribd company logo
GO: What’s Different ?
Tarun Vashisth
28th Sep 2018
Contents
• Programming Languages
• History
• Challenges
• Concurrency
• Object Oriented Design
• Type system and more
• Presence
• References
Languages
History
• 1950’s: Fortran, Lisp, Algol, Cobol
• 1960-70’s: B, Pascal, C, Prolog, SQL
• 1980’s: C++, Ada, Matlab, Erlang, Perl
• 1990’s(Internet age): Haskell, Python, VB, R, Ruby, Java, PHP,
JavaScript
• 2000’s: ActionScript, C#, D, Groovy, Scala, Clojure, Go, Rust, Kotlin,
Swift
• CULTURE ?
Challenges: Hardware limitations
• A fundamental turn towards concurrency in software
• Well, 3GHz CPUs -> 2004 and today -> MacBookPro@2.7GHz.
Challenges: Hardware limitations
• Resort to multicore
• Cannot scale indefinitely
• Comes with synchronization overhead between the operations.
• Increase transistor per unit area on chip?
Challenges: Multithreaded design
• Traditional programming languages -> 90’s -> traditional single-
threaded processes.
• Multi-threading
• Messy, complicated and expensive.
• Significant setup and teardown costs.
• We cool ?
Challenges: Multithreaded design
• Real problem:
• Concurrent execution
• Threading-locking
• Race conditions
• Deadlocks.
• Go: Designed keeping in mind multiple cores
• Famous paper “Communicating Sequential Processes” by C.A.R.
Hoare
Node.js: I don’t block
• Relatively easy to write and run
• Awesome V8 engine
• Event loop with promises
• NodeJS is single-threaded.
• It cannot directly use multi-core CPUs even though it is possible to
spawn different processes on several threads.
Node.js single threaded model
Go
• 2009 at Google by Rob Pike, Ken Thompson, Robert Griesemer.
• Primary motivation: Shared dislike of C++
• Slow compile times
• Standard Library offers no real support for Unicode
• Code bloat etc..
• Go is targeted as a modern C and especially as a replacement for C++.
Go
• Rethinks the traditional object-oriented development
• Effectively use all of the cores on your expensive server
• Go has a concise syntax with few keywords to memorize
• Fast complier: compiles to machine code
• Built in concurrency. NO to special threading libraries
Go: What's Different ?
Go
• Simple and effective type system
• Garbage collector: don’t have to manage your own memory.
• Spend less time waiting for your project to build
• Looks at the library that you directly include, rather than traversing
the dependencies of all the libraries that are included in the entire
dependency chain like Java, C, and C++.
• Taste: Objected Oriented and Functional Programming
Go: What's Different ?
Concurrency
• Concurrency vs Parallelism ?
• Concurrency: Programming as the composition of independently
executing processes.
• Parallelism: Programming as the simultaneous execution of (possibly
related) computations.
• Concurrency is about dealing with lots of things at once.
• Parallelism is about doing lots of things at once.
• Concurrency is about structure, parallelism is about execution.
Go: What's Different ?
Go supports concurrency
• Go provides:
• concurrent execution (goroutines)
• synchronization and messaging (channels)
• multi-way concurrent control (select)
• Goroutines come with built-in primitives to communicate safely
between themselves (channels).
• A single goroutine can run on multiple threads. Goroutines are
multiplexed into small number of OS threads.
• Goroutine is very cheap: 2kb vs 1MB(Java)
Objected Oriented Design
• No Inheritance ! No multi Inheritance problem.
• Go developers simply embed types to reuse functionality in a design
pattern called composition
• Interface: Allows you to model behavior
Type System and more
• Short variable declaration operator (:=)
• type interface{}
• Structs
• Anonymous function
• defer: To schedule a function call to be executed right after a function
returns.
Type System and more
• Receiver type for method declarations
• Main() and Init()
• Standard library
• Built in Testing, Benchmarking, Packing, Tooling
Presence
• Google
• Uber
• SoundCloud
• Walmart
• Docker
• Bitly
• BBC
• Basecamp
• DigitalOcean
• StackExchange
• Mozilla
• Lyft
• Blockchain
startups
• Facebook
• Twitter
• YouTube
• Apple
• Dropbox
• Github
• Games like Farmville
• IBM
• CoreOS
• GitLab
• InfluxData
• Intel
• Medium
Go: What's Different ?
References:
• https://en.wikipedia.org/wiki/Go_(programming_language)
• https://talks.golang.org
• https://hackernoon.com/why-go-ef8850dc5f3c
• Go in Action by Bill Kennedy
• https://medium.com/exploring-code/why-should-you-learn-go-
f607681fad65
• https://hackernoon.com/golang-or-the-future-of-the-dev-
984c2f145bbe
• https://gist.github.com/ungerik/3731476
THANK YOU

More Related Content

Go: What's Different ?

  • 1. GO: What’s Different ? Tarun Vashisth 28th Sep 2018
  • 2. Contents • Programming Languages • History • Challenges • Concurrency • Object Oriented Design • Type system and more • Presence • References
  • 4. History • 1950’s: Fortran, Lisp, Algol, Cobol • 1960-70’s: B, Pascal, C, Prolog, SQL • 1980’s: C++, Ada, Matlab, Erlang, Perl • 1990’s(Internet age): Haskell, Python, VB, R, Ruby, Java, PHP, JavaScript • 2000’s: ActionScript, C#, D, Groovy, Scala, Clojure, Go, Rust, Kotlin, Swift • CULTURE ?
  • 5. Challenges: Hardware limitations • A fundamental turn towards concurrency in software • Well, 3GHz CPUs -> 2004 and today -> MacBookPro@2.7GHz.
  • 6. Challenges: Hardware limitations • Resort to multicore • Cannot scale indefinitely • Comes with synchronization overhead between the operations. • Increase transistor per unit area on chip?
  • 7. Challenges: Multithreaded design • Traditional programming languages -> 90’s -> traditional single- threaded processes. • Multi-threading • Messy, complicated and expensive. • Significant setup and teardown costs. • We cool ?
  • 8. Challenges: Multithreaded design • Real problem: • Concurrent execution • Threading-locking • Race conditions • Deadlocks. • Go: Designed keeping in mind multiple cores • Famous paper “Communicating Sequential Processes” by C.A.R. Hoare
  • 9. Node.js: I don’t block • Relatively easy to write and run • Awesome V8 engine • Event loop with promises • NodeJS is single-threaded. • It cannot directly use multi-core CPUs even though it is possible to spawn different processes on several threads.
  • 11. Go • 2009 at Google by Rob Pike, Ken Thompson, Robert Griesemer. • Primary motivation: Shared dislike of C++ • Slow compile times • Standard Library offers no real support for Unicode • Code bloat etc.. • Go is targeted as a modern C and especially as a replacement for C++.
  • 12. Go • Rethinks the traditional object-oriented development • Effectively use all of the cores on your expensive server • Go has a concise syntax with few keywords to memorize • Fast complier: compiles to machine code • Built in concurrency. NO to special threading libraries
  • 14. Go • Simple and effective type system • Garbage collector: don’t have to manage your own memory. • Spend less time waiting for your project to build • Looks at the library that you directly include, rather than traversing the dependencies of all the libraries that are included in the entire dependency chain like Java, C, and C++. • Taste: Objected Oriented and Functional Programming
  • 16. Concurrency • Concurrency vs Parallelism ? • Concurrency: Programming as the composition of independently executing processes. • Parallelism: Programming as the simultaneous execution of (possibly related) computations. • Concurrency is about dealing with lots of things at once. • Parallelism is about doing lots of things at once. • Concurrency is about structure, parallelism is about execution.
  • 18. Go supports concurrency • Go provides: • concurrent execution (goroutines) • synchronization and messaging (channels) • multi-way concurrent control (select) • Goroutines come with built-in primitives to communicate safely between themselves (channels). • A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads. • Goroutine is very cheap: 2kb vs 1MB(Java)
  • 19. Objected Oriented Design • No Inheritance ! No multi Inheritance problem. • Go developers simply embed types to reuse functionality in a design pattern called composition • Interface: Allows you to model behavior
  • 20. Type System and more • Short variable declaration operator (:=) • type interface{} • Structs • Anonymous function • defer: To schedule a function call to be executed right after a function returns.
  • 21. Type System and more • Receiver type for method declarations • Main() and Init() • Standard library • Built in Testing, Benchmarking, Packing, Tooling
  • 22. Presence • Google • Uber • SoundCloud • Walmart • Docker • Bitly • BBC • Basecamp • DigitalOcean • StackExchange • Mozilla • Lyft • Blockchain startups • Facebook • Twitter • YouTube • Apple • Dropbox • Github • Games like Farmville • IBM • CoreOS • GitLab • InfluxData • Intel • Medium
  • 24. References: • https://en.wikipedia.org/wiki/Go_(programming_language) • https://talks.golang.org • https://hackernoon.com/why-go-ef8850dc5f3c • Go in Action by Bill Kennedy • https://medium.com/exploring-code/why-should-you-learn-go- f607681fad65 • https://hackernoon.com/golang-or-the-future-of-the-dev- 984c2f145bbe • https://gist.github.com/ungerik/3731476