SlideShare une entreprise Scribd logo
1  sur  72
Télécharger pour lire hors ligne
Gopher It
@gautamrege
Gautam Rege
https://flic.kr/p/7bgkPn
Gautam Rege
https://flic.kr/p/7bgkPn
https://flic.kr/p/9HfsBe
Gautam Rege
Rethink Programming
Rethink Programming
Why Go?
• See various features of Go
• Go code snippets
• Lot’s of gopher cartoons
@joshsoftware
Where Programming an Art!
Why was another
language required?
Arn’t there enough already?
https://flic.kr/p/bk3mFf
Picking a language?
Safety Speed
Ease
?
Type
Syntax Compilation
Runtime
IPC
Picking a language?
Safety Speed
Ease
?
Type
Syntax
Readable
Maintainable
Learning
Compilation
Runtime
IPC
Picking a language?
Safety Speed
Ease
?
Type
Syntax
Readable
Maintainable
Learning
Compilation
Runtime
IPC
Inspiration for Go
https://speakerdeck.com/bg/the-roots-of-go
Go is C on Steroids
Go is C on Steroids
Go is C on Steroids
No more
memory leaks
Go is C on Steroids
No more
memory leaks
Maps, Slices
Closures
Concurrency
Go is C on Steroids
No more
memory leaks
Maps, Slices
Closures
Concurrency
go fmt
go build
go get
go fix
Concurrency
Parallelism
Multi-core Processing
Concurrency is not Parallelism
Concurrency
Independent executing components
Parallelism
Execution in parallel
“Don’t communicate
by sharing memory.
Share memory by
communicating.”
Rob Pike
Concurrency and Parallelism
1 2 3 4
Concurrency and Parallelism
1 2 3 4
CSP
Communicating Sequential Processes
https://flic.kr/p/6MwYFo
CSP
Communicating Sequential Processes
https://flic.kr/p/awu6ZA
since 1978 !!
https://flic.kr/p/6MwYFo
Is Golang
Object Oriented?
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Access
Specifiers
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Access
Specifiers
Export with Case Sensitiveness
Exported / Unexported
“Nothing is really protected”
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Access
Specifiers
Structs, not classes
Embedded structs
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Inheritance
Structs, not classes
Embedded structs
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Inheritance
m
m
Structs, not classes
Embedded structs
type Attendee struct {
Name string
Country string
phone string
ticket string
}
type Speaker struct {
Attendee
slot time.Time
}
type Conference struct {
Name string
Location string
people []*Attendee
}
Inheritance
m
m
m
func (c *Conference) BuyTicket() (ticket string, err error)
{
//payment gateway stuff
return "R-00001", nil
}
func (person *Attendee) Attend(c *Conference) bool {
ticket, err := c.BuyTicket()
if err != nil {
// handle error
}
person.ticket = ticket
return true
}
Functions with Receivers
func (c *Conference) BuyTicket() (ticket string, err error)
{
//payment gateway stuff
return "R-00001", nil
}
func (person *Attendee) Attend(c *Conference) bool {
ticket, err := c.BuyTicket()
if err != nil {
// handle error
}
person.ticket = ticket
return true
}
Functions with Receivers
func (c *Conference) BuyTicket() (ticket string, err error)
{
//payment gateway stuff
return "R-00001", nil
}
func (person *Attendee) Attend(c *Conference) bool {
ticket, err := c.BuyTicket()
if err != nil {
// handle error
}
person.ticket = ticket
return true
}
Functions with Receivers
type SocialNetworker interface {
OnFacebook() string
OnTwitter() string
}
Interfaces
Don’t implement interfaces.
They happen!
type SocialNetworker interface {
OnFacebook() string
OnTwitter() string
}
Interfaces
func (Attendee) OnFacebook() string {
return “my fb account"
}
func (Attendee) OnTwitter() string {
return "my twitter account"
}
func (Conference) OnFacebook() string {
return "conf fb account"
}
func (Conference) OnTwitter() string {
return "conf twitter account"
}
Polymorphism
var social SocialNetworker
social = me // Attendee
fmt.Println("me: ", social.OnFacebook())
social = c // Conference
fmt.Println("me: ", social.OnFacebook())
Polymorphism
var social SocialNetworker
social = me // Attendee
fmt.Println("me: ", social.OnFacebook())
social = c // Conference
fmt.Println("me: ", social.OnFacebook())
Programming Ethics
Programmer Awareness
Programmer Awareness
Programmer Awareness
Programmer Awareness
Programmer Awareness
Programmer Awareness
y := 2 // y is of type int
y = "3"
Programming Awareness
y := 2 // y is of type int
y = "3"
Programming Awareness
Compile Error
Did you just
assign a string
to an integer?
Programming Awareness
confs := make(map[string]Conference)
for key, value := range confs {
fmt.Println(value.Name)
}
Programming Awareness
confs := make(map[string]Conference)
for key, value := range confs {
fmt.Println(value.Name)
}
Just saying - you should not
iterate a hash, man!
I’l randomise the order now!
defer
func trace(s string) { fmt.Println("entering:", s) }
func untrace(s string) { fmt.Println("leaving:", s) }
func main() {
trace("main")
defer untrace("main")
// do your thing.
}
defer
func trace(s string) { fmt.Println("entering:", s) }
func untrace(s string) { fmt.Println("leaving:", s) }
func main() {
trace("main")
defer untrace("main")
// do your thing.
}
func trace(s string) string {
fmt.Println("entering:", s)
return s
}
func main() {
defer untrace(trace(“main”))
// do your thing.
}
Concurrency and Parallelism
1 2 3 4
Concurrency and Parallelism
1 2 3 4
Goroutines
Concurrency and Parallelism
1 2 3 4
Channels
Ah… Some Go code (finally)
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
Packages
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
Channels
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
Channels
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
Go Routines
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
Writing to a Channel
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
Goroutines and defer
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exit
n", leg)
check_baton(leg, baton)
}
Reading from a Channel
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
// Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
}
fmt.Printf("Leg %d.. churned, waiting to exitn", leg)
check_baton(leg, baton)
}
func main() {
runtime.GOMAXPROCS(4)
baton := make(chan int)
wg.Add(4)
for i := 1; i < 5; i++ {
go run(i, baton)
}
// start the race
baton <- 1
// wait for relay to finish
wg.Wait()
}
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}
Go in Production
Smart City Technology
• Help / Panic / 911
• Complaints
• e-Wallet & e-Shopping
• Hospital Admission
• e-Cycle Management
• Township Surveillance
• Visitor Management
Utility Metering & Billing
• Water
• Electricity
• Gas
• Smart Distribution Box
Communication
• Internet
• DTH
• Telephony
• Video On Demand
• e-Learning
• Parking Management
• Bank Auto-debit
• Township Smart Debit card
• Hospital Admission
• e-Cycle Management
• Digital Door Locks
• Asset Tag Tracking
• Smart Street Lighting
Services
Security
Building Smart Cities
Building Smart Circuits
modbus
Ethernetmbus
wmbus
zigbee
Adoption of Go
Golang References
http://golang.org
https://tour.golang.org
https://golang.org/doc/effective_go.html
https://groups.google.com/group/golang-nuts
https://golang.org/play
http://blog.gopheracademy.com
http://www.goinggo.net
http://golang-challenge.com
Let the games begin !
@gautamrege
Gophers
@joshsoftware

Contenu connexe

Tendances

Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, GettLean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, GettDroidConTLV
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascriptReece Carlson
 
JIT compilation for CPython
JIT compilation for CPythonJIT compilation for CPython
JIT compilation for CPythondelimitry
 
FParsec Hands On - F#unctional Londoners 2014
FParsec Hands On -  F#unctional Londoners 2014FParsec Hands On -  F#unctional Londoners 2014
FParsec Hands On - F#unctional Londoners 2014Phillip Trelford
 
The algebra of library design
The algebra of library designThe algebra of library design
The algebra of library designLeonardo Borges
 
Unit 5
Unit 5Unit 5
Unit 5siddr
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageAnıl Sözeri
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler supportSyed Zaid Irshad
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageDroidConTLV
 
Arduino sectionprogramming slides
Arduino sectionprogramming slidesArduino sectionprogramming slides
Arduino sectionprogramming slidesJorge Joens
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageSmartLogic
 
Android dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWorkAndroid dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWorkDroidConTLV
 
Kotlin for android developers whats new
Kotlin for android developers whats newKotlin for android developers whats new
Kotlin for android developers whats newSerghii Chaban
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFDror Bereznitsky
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...Tsundere Chen
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinAndrey Breslav
 
Write Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 HoursWrite Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 HoursPhillip Trelford
 

Tendances (20)

Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, GettLean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
JIT compilation for CPython
JIT compilation for CPythonJIT compilation for CPython
JIT compilation for CPython
 
FParsec Hands On - F#unctional Londoners 2014
FParsec Hands On -  F#unctional Londoners 2014FParsec Hands On -  F#unctional Londoners 2014
FParsec Hands On - F#unctional Londoners 2014
 
The algebra of library design
The algebra of library designThe algebra of library design
The algebra of library design
 
Unit 5
Unit 5Unit 5
Unit 5
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler support
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritage
 
Arduino sectionprogramming slides
Arduino sectionprogramming slidesArduino sectionprogramming slides
Arduino sectionprogramming slides
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming Language
 
Android dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWorkAndroid dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWork
 
Kotlin for android developers whats new
Kotlin for android developers whats newKotlin for android developers whats new
Kotlin for android developers whats new
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in Kotlin
 
Write Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 HoursWrite Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 Hours
 

Similaire à WebSummit 2015 - Gopher it

Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#Paulo Morgado
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionPaulo Morgado
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
Unit 6
Unit 6Unit 6
Unit 6siddr
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfclarityvision
 
Introduction to go
Introduction to goIntroduction to go
Introduction to goJaehue Jang
 
Writing Docker monitoring agent with Go
Writing Docker monitoring agent with GoWriting Docker monitoring agent with Go
Writing Docker monitoring agent with GoNaoki AINOYA
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
 
Something about Golang
Something about GolangSomething about Golang
Something about GolangAnton Arhipov
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in GolangBo-Yi Wu
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdffazalenterprises
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATSKiwamu Okabe
 

Similaire à WebSummit 2015 - Gopher it (20)

About Go
About GoAbout Go
About Go
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
ProgrammingwithGOLang
ProgrammingwithGOLangProgrammingwithGOLang
ProgrammingwithGOLang
 
Unit 6
Unit 6Unit 6
Unit 6
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Fun with functions
Fun with functionsFun with functions
Fun with functions
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
 
Introduction to go
Introduction to goIntroduction to go
Introduction to go
 
Writing Docker monitoring agent with Go
Writing Docker monitoring agent with GoWriting Docker monitoring agent with Go
Writing Docker monitoring agent with Go
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
COMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdfCOMP360 Assembler Write an assembler that reads the source code of an.pdf
COMP360 Assembler Write an assembler that reads the source code of an.pdf
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATS
 

Plus de Gautam Rege

RubyConf India 2019 - Confessions of a rubypreneur
RubyConf India 2019 - Confessions of a rubypreneurRubyConf India 2019 - Confessions of a rubypreneur
RubyConf India 2019 - Confessions of a rubypreneurGautam Rege
 
GoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGautam Rege
 
Agile india 2017 - Rewarding OpenSource with $$$
Agile india 2017 - Rewarding OpenSource with $$$Agile india 2017 - Rewarding OpenSource with $$$
Agile india 2017 - Rewarding OpenSource with $$$Gautam Rege
 
WIDS - Gamifying Open Source
WIDS - Gamifying Open SourceWIDS - Gamifying Open Source
WIDS - Gamifying Open SourceGautam Rege
 
Gamifying Open Source
Gamifying Open SourceGamifying Open Source
Gamifying Open SourceGautam Rege
 
Affordable Smart Housing - The new revolution
Affordable Smart Housing - The new revolutionAffordable Smart Housing - The new revolution
Affordable Smart Housing - The new revolutionGautam Rege
 
Dont test your code
Dont test your codeDont test your code
Dont test your codeGautam Rege
 
Art of speaking at tech conferences
Art of speaking at tech conferencesArt of speaking at tech conferences
Art of speaking at tech conferencesGautam Rege
 
Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Gautam Rege
 
RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby Gautam Rege
 
ScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyGautam Rege
 
GCRC 2014 - The Dark Side of Ruby
GCRC 2014 - The Dark Side of RubyGCRC 2014 - The Dark Side of Ruby
GCRC 2014 - The Dark Side of RubyGautam Rege
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHPGautam Rege
 

Plus de Gautam Rege (14)

RubyConf India 2019 - Confessions of a rubypreneur
RubyConf India 2019 - Confessions of a rubypreneurRubyConf India 2019 - Confessions of a rubypreneur
RubyConf India 2019 - Confessions of a rubypreneur
 
GoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPH
 
Agile india 2017 - Rewarding OpenSource with $$$
Agile india 2017 - Rewarding OpenSource with $$$Agile india 2017 - Rewarding OpenSource with $$$
Agile india 2017 - Rewarding OpenSource with $$$
 
WIDS - Gamifying Open Source
WIDS - Gamifying Open SourceWIDS - Gamifying Open Source
WIDS - Gamifying Open Source
 
Gamifying Open Source
Gamifying Open SourceGamifying Open Source
Gamifying Open Source
 
Affordable Smart Housing - The new revolution
Affordable Smart Housing - The new revolutionAffordable Smart Housing - The new revolution
Affordable Smart Housing - The new revolution
 
Dont test your code
Dont test your codeDont test your code
Dont test your code
 
Art of speaking at tech conferences
Art of speaking at tech conferencesArt of speaking at tech conferences
Art of speaking at tech conferences
 
Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)
 
RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby
 
ScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyScotRuby - Dark side of ruby
ScotRuby - Dark side of ruby
 
GCRC 2014 - The Dark Side of Ruby
GCRC 2014 - The Dark Side of RubyGCRC 2014 - The Dark Side of Ruby
GCRC 2014 - The Dark Side of Ruby
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 

Dernier

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Dernier (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

WebSummit 2015 - Gopher it

  • 6. Rethink Programming Why Go? • See various features of Go • Go code snippets • Lot’s of gopher cartoons
  • 8. Why was another language required? Arn’t there enough already? https://flic.kr/p/bk3mFf
  • 9. Picking a language? Safety Speed Ease ? Type Syntax Compilation Runtime IPC
  • 10. Picking a language? Safety Speed Ease ? Type Syntax Readable Maintainable Learning Compilation Runtime IPC
  • 11. Picking a language? Safety Speed Ease ? Type Syntax Readable Maintainable Learning Compilation Runtime IPC
  • 13. Go is C on Steroids
  • 14. Go is C on Steroids
  • 15. Go is C on Steroids No more memory leaks
  • 16. Go is C on Steroids No more memory leaks Maps, Slices Closures Concurrency
  • 17. Go is C on Steroids No more memory leaks Maps, Slices Closures Concurrency go fmt go build go get go fix
  • 20. “Don’t communicate by sharing memory. Share memory by communicating.” Rob Pike
  • 23.
  • 24.
  • 28. type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Access Specifiers
  • 29. type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Access Specifiers
  • 30. Export with Case Sensitiveness Exported / Unexported “Nothing is really protected” type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Access Specifiers
  • 31. Structs, not classes Embedded structs type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Inheritance
  • 32. Structs, not classes Embedded structs type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Inheritance m m
  • 33. Structs, not classes Embedded structs type Attendee struct { Name string Country string phone string ticket string } type Speaker struct { Attendee slot time.Time } type Conference struct { Name string Location string people []*Attendee } Inheritance m m m
  • 34. func (c *Conference) BuyTicket() (ticket string, err error) { //payment gateway stuff return "R-00001", nil } func (person *Attendee) Attend(c *Conference) bool { ticket, err := c.BuyTicket() if err != nil { // handle error } person.ticket = ticket return true } Functions with Receivers
  • 35. func (c *Conference) BuyTicket() (ticket string, err error) { //payment gateway stuff return "R-00001", nil } func (person *Attendee) Attend(c *Conference) bool { ticket, err := c.BuyTicket() if err != nil { // handle error } person.ticket = ticket return true } Functions with Receivers
  • 36. func (c *Conference) BuyTicket() (ticket string, err error) { //payment gateway stuff return "R-00001", nil } func (person *Attendee) Attend(c *Conference) bool { ticket, err := c.BuyTicket() if err != nil { // handle error } person.ticket = ticket return true } Functions with Receivers
  • 37. type SocialNetworker interface { OnFacebook() string OnTwitter() string } Interfaces Don’t implement interfaces. They happen!
  • 38. type SocialNetworker interface { OnFacebook() string OnTwitter() string } Interfaces func (Attendee) OnFacebook() string { return “my fb account" } func (Attendee) OnTwitter() string { return "my twitter account" } func (Conference) OnFacebook() string { return "conf fb account" } func (Conference) OnTwitter() string { return "conf twitter account" }
  • 39. Polymorphism var social SocialNetworker social = me // Attendee fmt.Println("me: ", social.OnFacebook()) social = c // Conference fmt.Println("me: ", social.OnFacebook())
  • 40. Polymorphism var social SocialNetworker social = me // Attendee fmt.Println("me: ", social.OnFacebook()) social = c // Conference fmt.Println("me: ", social.OnFacebook())
  • 48. y := 2 // y is of type int y = "3" Programming Awareness
  • 49. y := 2 // y is of type int y = "3" Programming Awareness Compile Error Did you just assign a string to an integer?
  • 50. Programming Awareness confs := make(map[string]Conference) for key, value := range confs { fmt.Println(value.Name) }
  • 51. Programming Awareness confs := make(map[string]Conference) for key, value := range confs { fmt.Println(value.Name) } Just saying - you should not iterate a hash, man! I’l randomise the order now!
  • 52. defer func trace(s string) { fmt.Println("entering:", s) } func untrace(s string) { fmt.Println("leaving:", s) } func main() { trace("main") defer untrace("main") // do your thing. }
  • 53. defer func trace(s string) { fmt.Println("entering:", s) } func untrace(s string) { fmt.Println("leaving:", s) } func main() { trace("main") defer untrace("main") // do your thing. } func trace(s string) string { fmt.Println("entering:", s) return s } func main() { defer untrace(trace(“main”)) // do your thing. }
  • 55. Concurrency and Parallelism 1 2 3 4 Goroutines
  • 57. Ah… Some Go code (finally) package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() }
  • 58. Packages package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup
  • 59. Channels package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() }
  • 60. Channels package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() }
  • 61. Go Routines package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() }
  • 62. Writing to a Channel package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() }
  • 63. Goroutines and defer package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exit n", leg) check_baton(leg, baton) }
  • 64. Reading from a Channel package main import ( "fmt" "runtime" "sync" ) var wg sync.WaitGroup /* * Each go-routine sleeps at random(1-5) seconds. * This is simulating long working process * Then we finish in order */ func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } } func run(leg int, baton chan int) { defer wg.Done() fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn for count := 0; count < 300; count++ { for char := 0; char < 30000; char++ { fmt.Printf("") } } fmt.Printf("Leg %d.. churned, waiting to exitn", leg) check_baton(leg, baton) } func main() { runtime.GOMAXPROCS(4) baton := make(chan int) wg.Add(4) for i := 1; i < 5; i++ { go run(i, baton) } // start the race baton <- 1 // wait for relay to finish wg.Wait() } func check_baton(leg int, baton chan int) { for value := range baton { switch value { case leg: // pass the baton fmt.Println("Finished leg ", leg) if leg == 4 { close(baton) } else { baton <- leg + 1 } return default: // ignore baton <- value } } }
  • 66. Smart City Technology • Help / Panic / 911 • Complaints • e-Wallet & e-Shopping • Hospital Admission • e-Cycle Management • Township Surveillance • Visitor Management Utility Metering & Billing • Water • Electricity • Gas • Smart Distribution Box Communication • Internet • DTH • Telephony • Video On Demand • e-Learning • Parking Management • Bank Auto-debit • Township Smart Debit card • Hospital Admission • e-Cycle Management • Digital Door Locks • Asset Tag Tracking • Smart Street Lighting Services Security
  • 69.
  • 72. Let the games begin ! @gautamrege Gophers @joshsoftware