This document discusses the programming language Go and how it differs from other languages. It provides a brief history of programming languages from the 1950s to today. It then discusses challenges like hardware limitations and multithreaded design that led to the creation of Go. Go was created at Google in 2009 to better support concurrency and utilize multiple CPU cores. It has a simple syntax and type system, built-in concurrency using goroutines and channels, and sees adoption at many large tech companies.
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
13.
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
15.
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.
17.
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