SlideShare a Scribd company logo
Gopher It
@gautamrege
Gautam Rege
https://ïŹ‚ic.kr/p/7bgkPn
Gautam Rege
https://ïŹ‚ic.kr/p/7bgkPn
https://ïŹ‚ic.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://ïŹ‚ic.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 ïŹx
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
WebSummit 2015 - Gopher it
WebSummit 2015 - Gopher it
CSP
Communicating Sequential Processes
https://ïŹ‚ic.kr/p/6MwYFo
CSP
Communicating Sequential Processes
https://ïŹ‚ic.kr/p/awu6ZA
since 1978 !!
https://ïŹ‚ic.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
SpeciïŹers
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
SpeciïŹers
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
SpeciïŹers
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 (ïŹnally)
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
WebSummit 2015 - Gopher it
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

More Related Content

ODP
What's new in Perl 5.10?
 
PDF
Happy Go Programming
PDF
Vim Script Programming
PDF
RubyConf Portugal 2014 - Why ruby must go!
PDF
ATS language overview
PPTX
Cplusplus
 
PDF
A swift introduction to Swift
ODP
Python 3000
What's new in Perl 5.10?
 
Happy Go Programming
Vim Script Programming
RubyConf Portugal 2014 - Why ruby must go!
ATS language overview
Cplusplus
 
A swift introduction to Swift
Python 3000

What's hot (20)

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

Similar to WebSummit 2015 - Gopher it (20)

PPTX
Fundamental concurrent programming
PDF
Concurrency in Golang
PDF
Introduction to go
PDF
An Introduction to Go
PDF
Goroutines and Channels in practice
PPTX
Lightning talk: Go
 
ODP
Ready to go
PDF
Concurrency in Go by Denys Goldiner.pdf
PPT
Concurrency in go
KEY
Google Go Overview
PDF
Go concurrency
 
PDF
The async/await concurrency pattern in Golang
PDF
Concurrent Programming in Go basics and programming
PPTX
PPTX
Go. Why it goes
PDF
Something about Golang
PDF
Go, the one language to learn in 2014
PDF
JDD2014: GO! The one language you have to try in 2014 - Andrzej Grzesik
PDF
Go Concurrency
Fundamental concurrent programming
Concurrency in Golang
Introduction to go
An Introduction to Go
Goroutines and Channels in practice
Lightning talk: Go
 
Ready to go
Concurrency in Go by Denys Goldiner.pdf
Concurrency in go
Google Go Overview
Go concurrency
 
The async/await concurrency pattern in Golang
Concurrent Programming in Go basics and programming
Go. Why it goes
Something about Golang
Go, the one language to learn in 2014
JDD2014: GO! The one language you have to try in 2014 - Andrzej Grzesik
Go Concurrency
Ad

More from Gautam Rege (14)

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

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administration Chapter 2
PDF
System and Network Administraation Chapter 3
PPTX
Essential Infomation Tech presentation.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
PPTX
Transform Your Business with a Software ERP System
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
top salesforce developer skills in 2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
history of c programming in notes for students .pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Introduction to Artificial Intelligence
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administration Chapter 2
System and Network Administraation Chapter 3
Essential Infomation Tech presentation.pptx
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
Transform Your Business with a Software ERP System
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
top salesforce developer skills in 2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
history of c programming in notes for students .pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Introduction to Artificial Intelligence
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

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://ïŹ‚ic.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 ïŹx
  • 20. “Don’t communicate by sharing memory. Share memory by communicating.” Rob Pike
  • 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 SpeciïŹers
  • 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 SpeciïŹers
  • 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 SpeciïŹers
  • 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 (ïŹnally) 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
  • 72. Let the games begin ! @gautamrege Gophers @joshsoftware