Wonders of Golang

Kartik Sura
Kartik SuraSenior Software Engineer at Adap.tv
Wonders of Golang
Pain points of Systems Software
Change in computing landscape
Scale of development
Developer productivity
Dependency management
Wonders of Golang
Wonders of Golang
Enter Go
A new language,a concurrent, garbage-collected languagewith
fast compilation.
Syntax and Semantics
Similar to C
• compiled
• Statically typed
• Procedural with pointers
Small changes to C semantics
• No Pointer arithmetic
• No implicit numeric conversions
• Array bounds are always checked
Big changes
• Linguistic support for Concurrency
• Garbage collection
• Interface, reflection, type switches, etc.
Packages
• Modularity and reusability
• Componentize software
• Import clause
– import “fmt”
• Package name is used to qualify items
– Name vs. pkg.Name
• Remote packages
– import "github.com/garyburd/redigo"
Defining visibility using Naming
• Name of the identifier itself carries the visibility
– Upper case initial letter: Public/ exported/ visible to
other packages
– Lower case initial letter: Private to the package
Concurrency
• Do not communicate by sharing memory;
instead, share memory by communicating.
Goroutine
• Function executing concurrently with others in
same address space
• Lightweight
• Multiplexed into multiple OS threads
• Go keyword
Channels
• way for two goroutines to communicate with
one another and synchronize their execution
• By default, sends and receives block until the
other side is ready.
• Combine communication and synchronization
• Buffered channels
Channel
http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html
Buffered channel
Channel Idioms
• A channel can allow the launching goroutine
to wait for the sort to complete.
Server throughput
Request serving architectures
Cost of scheduling OS threads
• POSIX Threads: Signal mask, CPU affinity,
cgroups
• Store all the CPU registers
• Cost of context switch Vs amount of work
Goroutine scheduling
• Switched happen only at predefined times
– If channel operations are blocking
– Go statement
– Blocking syscalls like file and network IO
– Garbage collection
• Compiler knows which registers are used
Stack management
POSIX threads
• Large amount of
memory pre-reserved
• Amount of available
memory reduces with
increase in threads
Goroutine
• Starts with 2k
• A check before a
function call
• Shrinks with GC
OOP
Struct
Embedding
Multiple embedding
A golang-Interface is a class, with NO fields, and ALL VIRTUAL methods
When you call a method on the var/parameter, a concrete method is
called via method dispatch from a jmp-table.
Interface
Standard library
• Exp package for experimental new packages
• Archive and compresion: read .tar and .zip
• Bytes and String
• Collections: heap, lists
• File, OS
• Maths
• Networking: UNIX domain and network
sockets, TCP/IP, and UDP
Wonders of Golang
Tools
• Gofmt: single style for readability and
scalability
• Golint: checks style violations
• GoVet: finding common mistakes
• Inbuilt performance profiler
Wonders of Golang
Golang @ PubMatic
• Low latency high throughput
• Large number of network IO to external
partners
• Billions of requests per day
• Multiple go services live
• Third party components such as redis,
Aerospike, MySQL, GeoIP
We are hiring!
http://www.pubmatic.com/careers.php
GOPHERCON
• The Go Conference in India
• 19 - 20 February 2016
• Vivanta by Taj, MG Road, Bengaluru
• http://www.gophercon.in/
• Ticket is Rs 3999 (last 60 tickets remaining)
• Discount code D1000 for Rs 1000 off!
• https://www.townscript.com/e/gci16
1 de 31

Recomendados

Golang from Scala developer’s perspective por
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspectiveSveta Bozhko
2.6K vistas52 diapositivas
Golang - Overview of Go (golang) Language por
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
7.1K vistas85 diapositivas
GoLang Introduction por
GoLang IntroductionGoLang Introduction
GoLang IntroductionSpandana Govindgari
220 vistas25 diapositivas
Inroduction to golang por
Inroduction to golangInroduction to golang
Inroduction to golangYoni Davidson
484 vistas30 diapositivas
Golang por
GolangGolang
GolangSoftware Infrastructure
693 vistas48 diapositivas
Dependency management in golang por
Dependency management in golangDependency management in golang
Dependency management in golangRamit Surana
1.4K vistas20 diapositivas

Más contenido relacionado

La actualidad más candente

Optimizing and Profiling Golang Rest Api por
Optimizing and Profiling Golang Rest ApiOptimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest ApiIman Syahputra Situmorang
737 vistas31 diapositivas
Mphasis Digital - Use Go (gloang) for system programming, distributed systems... por
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Aniruddha Chakrabarti
472 vistas13 diapositivas
An introduction to go programming language por
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming languageTechnology Parser
4K vistas21 diapositivas
Go language presentation por
Go language presentationGo language presentation
Go language presentationparamisoft
4.9K vistas13 diapositivas
Coding with golang por
Coding with golangCoding with golang
Coding with golangHannahMoss14
320 vistas34 diapositivas
A First Look at Google's Go Programming Language por
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageGanesh Samarthyam
771 vistas23 diapositivas

La actualidad más candente(20)

Mphasis Digital - Use Go (gloang) for system programming, distributed systems... por Aniruddha Chakrabarti
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
An introduction to go programming language por Technology Parser
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
Technology Parser4K vistas
Go language presentation por paramisoft
Go language presentationGo language presentation
Go language presentation
paramisoft4.9K vistas
A First Look at Google's Go Programming Language por Ganesh Samarthyam
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
Ganesh Samarthyam771 vistas
10 reasons to be excited about go por Dvir Volk
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
Dvir Volk11.2K vistas
Building Command Line Tools with Golang por Takaaki Mizuno
Building Command Line Tools with GolangBuilding Command Line Tools with Golang
Building Command Line Tools with Golang
Takaaki Mizuno2.4K vistas
kikstart journey of Golang with Hello world - Gopherlabs por sangam biradar
kikstart journey of Golang with Hello world - Gopherlabs kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs
sangam biradar172 vistas
Go Programming Language by Google por Uttam Gandhi
Go Programming Language by GoogleGo Programming Language by Google
Go Programming Language by Google
Uttam Gandhi3.4K vistas
Understanding how concurrency work in os por GenchiLu1
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
GenchiLu1755 vistas
The Go programming language - Intro by MyLittleAdventure por mylittleadventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventure
mylittleadventure687 vistas
Introduction to go lang por Amal Mohan N
Introduction to go langIntroduction to go lang
Introduction to go lang
Amal Mohan N565 vistas
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno por Nexus FrontierTech
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
Nexus FrontierTech708 vistas
Go Programming language, golang por Basil N G
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
Basil N G655 vistas
How to write a well-behaved Python command line application por gjcross
How to write a well-behaved Python command line applicationHow to write a well-behaved Python command line application
How to write a well-behaved Python command line application
gjcross16.1K vistas
GO programming language por tung vu
GO programming languageGO programming language
GO programming language
tung vu2.1K vistas

Similar a Wonders of Golang

Go: What's Different ? por
Go: What's Different ?Go: What's Different ?
Go: What's Different ?Tarun Vashisth
24 vistas25 diapositivas
High Performance Systems in Go - GopherCon 2014 por
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014Derek Collison
19.5K vistas38 diapositivas
Making Wallstreet talk with GO (GO India Conference 2015) por
Making Wallstreet talk with GO (GO India Conference 2015)Making Wallstreet talk with GO (GO India Conference 2015)
Making Wallstreet talk with GO (GO India Conference 2015)Matthew Campbell
1.1K vistas32 diapositivas
Enter Cookbook: refactoring under a microscope por
Enter Cookbook: refactoring under a microscopeEnter Cookbook: refactoring under a microscope
Enter Cookbook: refactoring under a microscopeKamil Samigullin
588 vistas40 diapositivas
Protocol Buffers por
Protocol BuffersProtocol Buffers
Protocol BuffersSoftware Infrastructure
1.3K vistas23 diapositivas
Don’t turn your logs into cuneiform por
Don’t turn your logs into cuneiformDon’t turn your logs into cuneiform
Don’t turn your logs into cuneiformAndrey Rebrov
520 vistas43 diapositivas

Similar a Wonders of Golang(20)

High Performance Systems in Go - GopherCon 2014 por Derek Collison
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
Derek Collison19.5K vistas
Making Wallstreet talk with GO (GO India Conference 2015) por Matthew Campbell
Making Wallstreet talk with GO (GO India Conference 2015)Making Wallstreet talk with GO (GO India Conference 2015)
Making Wallstreet talk with GO (GO India Conference 2015)
Matthew Campbell1.1K vistas
Enter Cookbook: refactoring under a microscope por Kamil Samigullin
Enter Cookbook: refactoring under a microscopeEnter Cookbook: refactoring under a microscope
Enter Cookbook: refactoring under a microscope
Kamil Samigullin588 vistas
Don’t turn your logs into cuneiform por Andrey Rebrov
Don’t turn your logs into cuneiformDon’t turn your logs into cuneiform
Don’t turn your logs into cuneiform
Andrey Rebrov520 vistas
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012 por Blend Interactive
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
Blend Interactive10K vistas
Reading Notes : the practice of programming por Juggernaut Liu
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
Juggernaut Liu714 vistas
Python VS GO por Ofir Nir
Python VS GOPython VS GO
Python VS GO
Ofir Nir86 vistas
Managing Open Source Software in the GitHub Era por nexB Inc.
Managing Open Source Software in the GitHub EraManaging Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub Era
nexB Inc.979 vistas
computer-science_engineering_principles-of-programming-languages_introduction... por AshutoshSharma874829
computer-science_engineering_principles-of-programming-languages_introduction...computer-science_engineering_principles-of-programming-languages_introduction...
computer-science_engineering_principles-of-programming-languages_introduction...
Rest style web services (google protocol buffers) prasad nirantar por IndicThreads
Rest style web services (google protocol buffers)   prasad nirantarRest style web services (google protocol buffers)   prasad nirantar
Rest style web services (google protocol buffers) prasad nirantar
IndicThreads3K vistas
Performance and Abstractions por Metosin Oy
Performance and AbstractionsPerformance and Abstractions
Performance and Abstractions
Metosin Oy1.1K vistas
LCA14: LCA14-209: ODP Project Update por Linaro
LCA14: LCA14-209: ODP Project UpdateLCA14: LCA14-209: ODP Project Update
LCA14: LCA14-209: ODP Project Update
Linaro1K vistas
EuroMPI 2013 presentation: McMPI por Dan Holmes
EuroMPI 2013 presentation: McMPIEuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPI
Dan Holmes624 vistas
Introduction to Python Programming por Akhil Kaushik
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik322 vistas
Getting Started with Go por Steven Francia
Getting Started with GoGetting Started with Go
Getting Started with Go
Steven Francia39.8K vistas

Último

Agile 101 por
Agile 101Agile 101
Agile 101John Valentino
9 vistas20 diapositivas
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... por
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Donato Onofri
860 vistas34 diapositivas
Ports-and-Adapters Architecture for Embedded HMI por
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMIBurkhard Stubert
21 vistas19 diapositivas
360 graden fabriek por
360 graden fabriek360 graden fabriek
360 graden fabriekinfo33492
122 vistas25 diapositivas
Short_Story_PPT.pdf por
Short_Story_PPT.pdfShort_Story_PPT.pdf
Short_Story_PPT.pdfutkarshsatishkumarsh
5 vistas16 diapositivas
Bootstrapping vs Venture Capital.pptx por
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
12 vistas17 diapositivas

Último(20)

Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... por Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri860 vistas
Ports-and-Adapters Architecture for Embedded HMI por Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert21 vistas
360 graden fabriek por info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492122 vistas
Bootstrapping vs Venture Capital.pptx por Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic12 vistas
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... por Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 vistas
Navigating container technology for enhanced security by Niklas Saari por Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 vistas
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx por animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 vistas
FIMA 2023 Neo4j & FS - Entity Resolution.pptx por Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j8 vistas
Top-5-production-devconMunich-2023.pptx por Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app7 vistas
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... por sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik7 vistas
Sprint 226 por ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ5 vistas

Wonders of Golang

  • 2. Pain points of Systems Software Change in computing landscape Scale of development Developer productivity Dependency management
  • 5. Enter Go A new language,a concurrent, garbage-collected languagewith fast compilation.
  • 6. Syntax and Semantics Similar to C • compiled • Statically typed • Procedural with pointers Small changes to C semantics • No Pointer arithmetic • No implicit numeric conversions • Array bounds are always checked Big changes • Linguistic support for Concurrency • Garbage collection • Interface, reflection, type switches, etc.
  • 7. Packages • Modularity and reusability • Componentize software • Import clause – import “fmt” • Package name is used to qualify items – Name vs. pkg.Name • Remote packages – import "github.com/garyburd/redigo"
  • 8. Defining visibility using Naming • Name of the identifier itself carries the visibility – Upper case initial letter: Public/ exported/ visible to other packages – Lower case initial letter: Private to the package
  • 9. Concurrency • Do not communicate by sharing memory; instead, share memory by communicating.
  • 10. Goroutine • Function executing concurrently with others in same address space • Lightweight • Multiplexed into multiple OS threads • Go keyword
  • 11. Channels • way for two goroutines to communicate with one another and synchronize their execution • By default, sends and receives block until the other side is ready. • Combine communication and synchronization • Buffered channels
  • 14. Channel Idioms • A channel can allow the launching goroutine to wait for the sort to complete.
  • 17. Cost of scheduling OS threads • POSIX Threads: Signal mask, CPU affinity, cgroups • Store all the CPU registers • Cost of context switch Vs amount of work
  • 18. Goroutine scheduling • Switched happen only at predefined times – If channel operations are blocking – Go statement – Blocking syscalls like file and network IO – Garbage collection • Compiler knows which registers are used
  • 19. Stack management POSIX threads • Large amount of memory pre-reserved • Amount of available memory reduces with increase in threads Goroutine • Starts with 2k • A check before a function call • Shrinks with GC
  • 20. OOP
  • 24. A golang-Interface is a class, with NO fields, and ALL VIRTUAL methods When you call a method on the var/parameter, a concrete method is called via method dispatch from a jmp-table. Interface
  • 25. Standard library • Exp package for experimental new packages • Archive and compresion: read .tar and .zip • Bytes and String • Collections: heap, lists • File, OS • Maths • Networking: UNIX domain and network sockets, TCP/IP, and UDP
  • 27. Tools • Gofmt: single style for readability and scalability • Golint: checks style violations • GoVet: finding common mistakes • Inbuilt performance profiler
  • 29. Golang @ PubMatic • Low latency high throughput • Large number of network IO to external partners • Billions of requests per day • Multiple go services live • Third party components such as redis, Aerospike, MySQL, GeoIP
  • 31. GOPHERCON • The Go Conference in India • 19 - 20 February 2016 • Vivanta by Taj, MG Road, Bengaluru • http://www.gophercon.in/ • Ticket is Rs 3999 (last 60 tickets remaining) • Discount code D1000 for Rs 1000 off! • https://www.townscript.com/e/gci16

Notas del editor

  1. Most of the popular languages used for systems development, such as C C++ Java have been created for an environment which has changed a lot in the last few years. The problems introduced by multicore processors, networked systems, massive computation clusters, and the web programming model were being worked around rather than addressed head-on. Fundamental concepts such as garbage collection and parallel computation were not supported by popular languages. The scale has changed: today's server programs comprise tens of millions of lines of code, are worked on by hundreds or even thousands of programmers, and are updated literally every day. To make matters worse, build times, even on large compilation clusters, have stretched to many minutes, even hours. Lot of developers are early in their careers and are used to procedural languages. It takes lot of time and effort to become productive in a language. People are used to languages such as C C++ Java and Java Script. Each programmer uses a subset of the language. Poor program understanding (code hard to read, poorly documented) Duplication of efforts: Lack of standard library support for commonly used data strcutures, networking and other routinely used algorithms results in duplication of efforts in implementing them. Dependency management is important for clean dependency analysis—and fast compilation. “header files” of languages in the C tradition #ifndef guards: Idea is that header file is bracked with the conditional compilation clause, so that the file can be included multiple times without error. Source of unix ps command has stat.h included 37 times. Even if the contents are discarded, the file is opened, read and scanned 37 times. One interesting data point from Google: The code of a google binary concatenated together, was around 4.2 MB. By the time the #inlcude had been expanded, it blew over to 8GB as input to the compiler, that is a massive 2000x blowup. Another data point: Google updated their build system from a single makefile, to a per-directory design with more clear dependencies. The binary shrunk by 40% just by clear dependencies. The consequence of uncontrolled dependencies is that Google has to maintain a distributed compilation system costing huge engineering effort.
  2. Requirements for a language to succeed in the systems development environment: It must work at scale, for large programs with large numbers of dependencies, with large teams of programmers working on them. It must be familiar, roughly C-like. The need to get programmers productive quickly in a new language means that the language cannot be too radical. It must be modern. There are features of the modern world that are better met by newer approaches, such as built-in concurrency. Regarding the points above: It is possible to compile a large Go program in a few seconds on a single computer. Go makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries. Type system has no hierarchy Go is fully garbage-collected and provides fundamental support for concurrent execution and communication. Go supports the construction of system software on multicore machines. It is common to have thousands of goroutines on a moderately sized server
  3. syntax determines the readability and hence clarity of the language. Also, syntax is critical to tooling: if the language is hard to parse, automated tools are hard to write. Go was therefore designed with clarity and tooling in mind, and has a clean syntax. the grammar is regular and therefore easy to parse
  4. Go provides the modularity and code reusability through it’s package ecosystem write small pieces of software components through packages, and compose your  applications with these small packages. the package path can refer to remote repositories by having it identify the URL of the site serving the repository.
  5. it's always clear when looking at an identifier whether it is part of the public API. After using Go for a while, it feels burdensome when going back to other languages that require looking up the declaration to discover this information
  6. Concurrent programming in many environments is made difficult by the subtleties required to implement correct access to shared variables Go encourages a different approach in which shared values are passed around on channels Only one goroutine has access to the vaue at any given time. Data races cannot occur, by design
  7. Goroutines are multiplexed onto multiple OS threads so if one should block, such as while waiting for I/O, others continue to run. Their design hides many of the complexities of thread creation and management.
  8. By default, sends and receives block until the other side is ready. This allows goroutines to synchronize without explicit locks or condition variables. If the channel has a buffer, the sender blocks only until the value has been copied to the buffer; if the buffer is full, this means blocking until some receiver has retrieved a value. A buffered channel can be used like a semaphore, for instance to limit throughput.
  9. The throughput of a server follows a bell curve, as shown in the figure After the peak output, the server starts spending more time scheduling the requests, rather than serving the requests, resulting into increasing number of timeouts and errors
  10. Thread per request: The bottleneck of low latency high scale systems is the number of threads handled by the OS (not RAM, CPU, Bandwidth). The code is simple to develop and debug. Either go for event based model or lightweight threads Event-based programming has been highly touted in recent years as the best way to write highly concurrent applications. Event based systems are promising but it has a steep learning curve and dependent complexities.
  11. Threads have their own signal mask, can be assigned CPU affinity, can be put into cgroups and can be queried for which resources they use. All these controls add overhead for they quickly add up when you have 100,000 threads in your program. The kernel needs to store the contents of all the CPU registers for that process, then restore the values for another process. Because a process switch can occur at any point in a process’ execution, the operating system needs to store the contents of all of these registers because it does not know which are currently in use 2. The kernel needs to flush the CPU’s virtual address to physical address mappings (TLB cache) These costs are relatively fixed by the hardware, and depend on the amount of work done between context switches to amortise their cost—rapid context switching tends to overwhelm the amount of work done between context switches.
  12. Instead of using guard pages, the Go compiler inserts a check as part of every function call to test if there is sufficient stack for the function to run. If there is sufficient stack space, the function runs as normal. If there is insufficient space, the runtime will allocate a larger stack segment on the heap, copy the contents of the current stack to the new segment, free the old segment, and the function call is restarted. Because of this check, a goroutine’s initial stack can be made much smaller, which in turn permits Go programmers to treat goroutines as cheap resources. Goroutine stacks can also shrink if a sufficient portion remains unused. This is handled during garbage collection
  13. By embedding a struct into another you have a mechanism similar to multiple inheritance After embedding, the base fields and methods are directly available in the derived struct
  14. If you have a method show() for example in class/struct NamedObj and also define a method show() in class/struct Rectangle, Rectangle/show() will SHADOW the parent's class NamedObj/Show() Golang solves the diamond problem by not allowing diamonds.
  15. The exp (experimental) package is where packages that might potentially be added to the standard library begin life, so these packages should not be used unless you want to participate in their development (by testing, commenting, or submitting patches). T
  16. Go's syntax, package system, naming conventions, and other features were designed to make tools easy to write, and the library includes a lexer, parser, and type checker for the language.