SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
10 Reasons to be
Excited About
Go
Dvir Volk, Chief Architect,
Everything.me
O HAI! I CAN HAS A GO?
What is Go
● New-ish programming language developed
at Google (and used there)
● Targeted for high performance servers
● Focuses on easing the life of the developer
● Addresses real pains - mainly from C++
● Object-Oriented-ish
● Statically Compiled
● Garbage Collected
● Strictly Typed
● Concurrency Oriented
Reason 1: The syntax
● Simple, Quick learning curve, little code to write.
● Few keywords - e.g.: do, while, for
● Multiple return values
● Public / private
● Maps, slices (vectors), queues as first class members
● Pointers - without arithmetic
● No macros
● No exceptions
● No templates
● No operator overloading
● No warnings!
The syntax: Hello World
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
The syntax: Variables, looping
package main
import "fmt"
func main() {
a, b := 1, 2
fmt.Printf("a + b: %dn", a + b)
for a < 100 {
a++
fmt.Println(a)
}
}
The syntax: Imports, casting
package main
import (
"fmt"
"math"
)
func main() {
for i := 0; i < 100; i++ {
fmt.Println(math.Pow(float64(i), 2))
}
}
The syntax: Funcs
package main
import (
"fmt"
// "math"
)
func square(i int) int {
return i*i
}
func main() {
for i := 0; i < 100; i++ {
fmt.Println(i, square(i))
}
}
The syntax: Structs & Methods
type User struct {
Name string
password string
}
// This is a method for User
func (u *User) Authenticate(name, password string) bool {
return u.Name == name && u.password == password
}
// Instead of constructors...
func NewUser(name, password string) *User {
return &User{ Name: name, password: password, }
}
// Instead of inheritence...
type Administrator struct {
User
email string
}
func (a *Administrator) SendMail(msg string) {
log.Println("Sending message to ", a.Name)
}
Reason 2: Compiler Speed
● The whole SDK and compiler compiled in 19 seconds.
● Standard library - a couple of seconds. For 370 KLOC.
● My own project, 5 KLOC - 0.186 seconds.
Why?
● Compiling imports only directly imported stuff.
● Compiler friendly syntax.
● The language is very small.
● Unused imports not allowed.
● Circular imports not allowed (no #IFDEF).
Reason 3: Execution Speed
● Go is FAST
● Slower usually than C++, not by a lot.
● More or less on par with Java
● about x10 to x100 faster than Python/Ruby
● (but let's not forget concurrency)
● Only gcc-go does machine code
optimizations
● Significant performance improvements
between versions.
Execution Speed: Go vs. C++
(Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
Execution Speed: Go vs. Java
(Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
Execution Speed: Go vs. Ruby
(Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
Reason 4: The Ecosystem
● Go Get - a pip/gem like installation system
● Compliant with Github / Google Code,
Bitbucket
● Any repo can be made compliant
● The repo url is also the namespace!
● Can be automated to run on compile time
● Excellent repo search engines
● Friendly, useful community
Importing a package: Example
package main
import (
"github.com/dvirsky/go-pylog/logging"
)
func main() {
logging.Info("All Your Base Are Belong to %s!", "us")
logging.Critical("And now with a stack trace")
}
Reason 5: Simple Conventions
● Lots of convention-over-configuration:
● all tests & benchmarks in *_test.go - just hit
go test
● func TestXXX(t *testing.T) {}
● func BenchmarkXXX(b *testing.B) {}
● func ExampleFoo() {}
● Excellent documentation system built-in
● Folders are packages, URLs for installed
● Public / private
Documentation & Examples: Input
Documentation & Examples: Output
Reason 6: Concurrency
● Goroutines and Channels are the heart of
Go
● Goroutines are microthreads with an internal
scheduler
● You can run 10Ks of goroutines easily
● No need for non-blocking IO. It is under the
hood!
● The usual pattern: One goroutine per server
connection
● Locks are available but not encouraged
Concurrency: Channels
● Channels are synchronized message
queues between goroutines.
● They are strictly typed first-class citizens.
● Delegate state through channels instead of
sharing it.
● Buffered channels for non blocking pushes.
● They can be iterated on.
Channels: Over-simplified example...
func producer(c chan string) {
for i := 0; i < 100; i++ {
c <- fmt.Sprintf("Message #%d", i)
}
close(c)
}
func main() {
c := make(chan string)
go producer(c)
for s := range c {
fmt.Println(s)
}
}
Channels: Slightly more complex #1
package main
import (
"fmt"
"runtime"
)
type result struct {
in int
out int
}
//worker getting numbers and sending back their sqaure
func squarer(in chan int, out chan result) {
for i := range in {
out <- result{i, i * i}
}
}
//take in the results and print them
func aggregator(res chan result) {
for s := range res {
fmt.Println(s)
}
}
// TO BE CONTINUED ON NEXT SLIDE ------>
Channels: Slightly more complex #2
func main() {
//utilize all CPUs
runtime.GOMAXPROCS(runtime.NumCPU())
//create the channels
inChan := make(chan int)
outChan := make(chan result)
//fire up the workers
for i := 0; i < 10; i++ {
go squarer(inChan, outChan)
}
//aggregate results
go aggregator(outChan)
//push the input
for i := 0; i < 1000; i++ {
inChan <- i
}
//there are prettier ways of blocking here... :)
var input string
fmt.Scanln(&input)
}
Reason 7: The standard library
● Excellent, rich standard library
● More like Python's than C++'s
● Very well documented
● Great source for idiomatic code
● Excellent serialization
Reason 7: The standard library
● The "Batteries" include:
○ Robust HTTP Web Server + template library
○ Compression, encryption, JSON / XML / CSV
○ Profiling, debugging, source parsing
○ Reflection library
○ Image manipulation
○ Plus the usual suspects
○ No GUI Toolkit :)
The standard library: A Web Server
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!" , r.URL.Path[1:])
}
func main() {
http.HandleFunc( "/", handler)
http.ListenAndServe( ":8080", nil)
}
Reason 8: C is never too far
● CGo is part of the standard library
● Makes binding C libraries trivial
● You can also trivially call Go code from C
● BTW: A JVM based Go exists ;)
package rand
/*
#include <stdlib.h>
*/
import "C"
func Random() int {
return int(C.rand())
}
func Seed(i int) {
C.srand(C. uint(i))
}
Reason 9: Implicit Interfaces
● Implementing an interface simply means you
implement it, no declaration needed.
● Example: any struct that has a method
String() string can be used for "%s" fmt
● You can mix and match interfaces as you go
● The empty interface, interface{} is super
useful.
● Interfaces can be safely cast into structs, or
called directly.
Reason 10: Procrastination It's Fun!
● Go is fun to work on and read about
● Beware: productive procrastination :)
● "Code is compiling" is no longer valid!
● Thank God we have a new excuse
Before we get too excited
● Lack of complete, real IDE
● Debugging: GDB Works great - but no real
frontend
● No dynamic linking/loading
● Implicit interfaces are cool but can be
confusing
● No exceptions - a matter of taste.
Wanna write some Go code?
We're hiring! :)
We're introducing Go to our backend and data
crunching stack, where C++ used to roam, or
where Go could kick Python's ass.
Email jobs@everything.me
A Few Good Resources
● The official website:
http://golang.org/
● Excellent introductory book:
http://www.golang-book.com/
● GoDoc: Package search
http://godoc.org/
● Migrating from Python to Go:
http://blog.repustate.com/migrating-code-from-python-
to-golang-what-you-need-to-know/2013/04/23/

Más contenido relacionado

La actualidad más candente

Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of GolangKartik Sura
 
Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...sangam biradar
 
Introduction to Go programming language
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming languageSlawomir Dorzak
 
GO programming language
GO programming languageGO programming language
GO programming languagetung vu
 
Go language presentation
Go language presentationGo language presentation
Go language presentationparamisoft
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go languageTzar Umang
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
Golang from Scala developer’s perspective
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspectiveSveta Bozhko
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in osGenchiLu1
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialRomin Irani
 
How to write a well-behaved Python command line application
How to write a well-behaved Python command line applicationHow to write a well-behaved Python command line application
How to write a well-behaved Python command line applicationgjcross
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golangYoni Davidson
 
Come With Golang
Come With GolangCome With Golang
Come With Golang尚文 曾
 
Beginning python programming
Beginning python programmingBeginning python programming
Beginning python programmingkanteshraj
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency designHyejong
 
Infecting Python Bytecode
Infecting Python BytecodeInfecting Python Bytecode
Infecting Python BytecodeIftach Ian Amit
 
Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015Jian-Hong Pan
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golangRamit Surana
 

La actualidad más candente (20)

Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of Golang
 
Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...
 
Introduction to Go programming language
Introduction to Go programming languageIntroduction to Go programming language
Introduction to Go programming language
 
GO programming language
GO programming languageGO programming language
GO programming language
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go language
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Golang from Scala developer’s perspective
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspective
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop Material
 
How to write a well-behaved Python command line application
How to write a well-behaved Python command line applicationHow to write a well-behaved Python command line application
How to write a well-behaved Python command line application
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golang
 
Golang for OO Programmers
Golang for OO ProgrammersGolang for OO Programmers
Golang for OO Programmers
 
Come With Golang
Come With GolangCome With Golang
Come With Golang
 
Beginning python programming
Beginning python programmingBeginning python programming
Beginning python programming
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
 
Infecting Python Bytecode
Infecting Python BytecodeInfecting Python Bytecode
Infecting Python Bytecode
 
Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golang
 

Destacado

Google Go! language
Google Go! languageGoogle Go! language
Google Go! languageAndré Mayer
 
An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming languageTechnology Parser
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkDvir Volk
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)Aaron Schlesinger
 
Go: Beyond the Basics
Go: Beyond the BasicsGo: Beyond the Basics
Go: Beyond the BasicsJoey Gibson
 
Tales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningTales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningDvir Volk
 
CloudEndure Technology Introduction For Partners
CloudEndure Technology Introduction For PartnersCloudEndure Technology Introduction For Partners
CloudEndure Technology Introduction For PartnersThe Rudder Group
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)상욱 송
 
Amazon Web Services and Docker
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and DockerPaolo latella
 
Docker: automation for the rest of us
Docker: automation for the rest of usDocker: automation for the rest of us
Docker: automation for the rest of usJérôme Petazzoni
 
Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?Jérôme Petazzoni
 
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...Jérôme Petazzoni
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101Dvir Volk
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Itamar Haber
 
A microservice architecture based on golang
A microservice architecture based on golangA microservice architecture based on golang
A microservice architecture based on golangGianfranco Reppucci
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux ContainerBalaji Rajan
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 

Destacado (20)

Golang
GolangGolang
Golang
 
Google Go! language
Google Go! languageGoogle Go! language
Google Go! language
 
An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
 
Go lang
Go langGo lang
Go lang
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and Spark
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 
Go: Beyond the Basics
Go: Beyond the BasicsGo: Beyond the Basics
Go: Beyond the Basics
 
Tales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningTales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe running
 
CloudEndure Technology Introduction For Partners
CloudEndure Technology Introduction For PartnersCloudEndure Technology Introduction For Partners
CloudEndure Technology Introduction For Partners
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
Amazon Web Services and Docker
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and Docker
 
Docker: automation for the rest of us
Docker: automation for the rest of usDocker: automation for the rest of us
Docker: automation for the rest of us
 
Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?
 
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
A microservice architecture based on golang
A microservice architecture based on golangA microservice architecture based on golang
A microservice architecture based on golang
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 

Similar a 10 Reasons to Get Excited About Go

Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016maiktoepfer
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java DevelopersLaszlo Csontos
 
Golang getting started
Golang getting startedGolang getting started
Golang getting startedHarshad Patil
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golangBasil N G
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experimentAmos Wenger
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experimentAmos Wenger
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Godreamwidth
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8Phil Eaton
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in GoAmr Hassan
 
Concurrency in go
Concurrency in goConcurrency in go
Concurrency in goborderj
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGlobalLogic Ukraine
 

Similar a 10 Reasons to Get Excited About Go (20)

Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
Go. why it goes v2
Go. why it goes v2Go. why it goes v2
Go. why it goes v2
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java Developers
 
Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Golang getting started
Golang getting startedGolang getting started
Golang getting started
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Go
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
 
Concurrency in go
Concurrency in goConcurrency in go
Concurrency in go
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii Shapoval
 
C Lecture
C LectureC Lecture
C Lecture
 

Último

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 

Último (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 

10 Reasons to Get Excited About Go

  • 1. 10 Reasons to be Excited About Go Dvir Volk, Chief Architect, Everything.me
  • 2. O HAI! I CAN HAS A GO?
  • 3. What is Go ● New-ish programming language developed at Google (and used there) ● Targeted for high performance servers ● Focuses on easing the life of the developer ● Addresses real pains - mainly from C++ ● Object-Oriented-ish ● Statically Compiled ● Garbage Collected ● Strictly Typed ● Concurrency Oriented
  • 4. Reason 1: The syntax ● Simple, Quick learning curve, little code to write. ● Few keywords - e.g.: do, while, for ● Multiple return values ● Public / private ● Maps, slices (vectors), queues as first class members ● Pointers - without arithmetic ● No macros ● No exceptions ● No templates ● No operator overloading ● No warnings!
  • 5. The syntax: Hello World package main import "fmt" func main() { fmt.Println("Hello World!") }
  • 6. The syntax: Variables, looping package main import "fmt" func main() { a, b := 1, 2 fmt.Printf("a + b: %dn", a + b) for a < 100 { a++ fmt.Println(a) } }
  • 7. The syntax: Imports, casting package main import ( "fmt" "math" ) func main() { for i := 0; i < 100; i++ { fmt.Println(math.Pow(float64(i), 2)) } }
  • 8. The syntax: Funcs package main import ( "fmt" // "math" ) func square(i int) int { return i*i } func main() { for i := 0; i < 100; i++ { fmt.Println(i, square(i)) } }
  • 9. The syntax: Structs & Methods type User struct { Name string password string } // This is a method for User func (u *User) Authenticate(name, password string) bool { return u.Name == name && u.password == password } // Instead of constructors... func NewUser(name, password string) *User { return &User{ Name: name, password: password, } } // Instead of inheritence... type Administrator struct { User email string } func (a *Administrator) SendMail(msg string) { log.Println("Sending message to ", a.Name) }
  • 10. Reason 2: Compiler Speed ● The whole SDK and compiler compiled in 19 seconds. ● Standard library - a couple of seconds. For 370 KLOC. ● My own project, 5 KLOC - 0.186 seconds. Why? ● Compiling imports only directly imported stuff. ● Compiler friendly syntax. ● The language is very small. ● Unused imports not allowed. ● Circular imports not allowed (no #IFDEF).
  • 11. Reason 3: Execution Speed ● Go is FAST ● Slower usually than C++, not by a lot. ● More or less on par with Java ● about x10 to x100 faster than Python/Ruby ● (but let's not forget concurrency) ● Only gcc-go does machine code optimizations ● Significant performance improvements between versions.
  • 12. Execution Speed: Go vs. C++ (Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
  • 13. Execution Speed: Go vs. Java (Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
  • 14. Execution Speed: Go vs. Ruby (Data: The benchmark game, http://benchmarksgame.alioth.debian.org/)
  • 15. Reason 4: The Ecosystem ● Go Get - a pip/gem like installation system ● Compliant with Github / Google Code, Bitbucket ● Any repo can be made compliant ● The repo url is also the namespace! ● Can be automated to run on compile time ● Excellent repo search engines ● Friendly, useful community
  • 16. Importing a package: Example package main import ( "github.com/dvirsky/go-pylog/logging" ) func main() { logging.Info("All Your Base Are Belong to %s!", "us") logging.Critical("And now with a stack trace") }
  • 17. Reason 5: Simple Conventions ● Lots of convention-over-configuration: ● all tests & benchmarks in *_test.go - just hit go test ● func TestXXX(t *testing.T) {} ● func BenchmarkXXX(b *testing.B) {} ● func ExampleFoo() {} ● Excellent documentation system built-in ● Folders are packages, URLs for installed ● Public / private
  • 20. Reason 6: Concurrency ● Goroutines and Channels are the heart of Go ● Goroutines are microthreads with an internal scheduler ● You can run 10Ks of goroutines easily ● No need for non-blocking IO. It is under the hood! ● The usual pattern: One goroutine per server connection ● Locks are available but not encouraged
  • 21. Concurrency: Channels ● Channels are synchronized message queues between goroutines. ● They are strictly typed first-class citizens. ● Delegate state through channels instead of sharing it. ● Buffered channels for non blocking pushes. ● They can be iterated on.
  • 22. Channels: Over-simplified example... func producer(c chan string) { for i := 0; i < 100; i++ { c <- fmt.Sprintf("Message #%d", i) } close(c) } func main() { c := make(chan string) go producer(c) for s := range c { fmt.Println(s) } }
  • 23. Channels: Slightly more complex #1 package main import ( "fmt" "runtime" ) type result struct { in int out int } //worker getting numbers and sending back their sqaure func squarer(in chan int, out chan result) { for i := range in { out <- result{i, i * i} } } //take in the results and print them func aggregator(res chan result) { for s := range res { fmt.Println(s) } } // TO BE CONTINUED ON NEXT SLIDE ------>
  • 24. Channels: Slightly more complex #2 func main() { //utilize all CPUs runtime.GOMAXPROCS(runtime.NumCPU()) //create the channels inChan := make(chan int) outChan := make(chan result) //fire up the workers for i := 0; i < 10; i++ { go squarer(inChan, outChan) } //aggregate results go aggregator(outChan) //push the input for i := 0; i < 1000; i++ { inChan <- i } //there are prettier ways of blocking here... :) var input string fmt.Scanln(&input) }
  • 25. Reason 7: The standard library ● Excellent, rich standard library ● More like Python's than C++'s ● Very well documented ● Great source for idiomatic code ● Excellent serialization
  • 26. Reason 7: The standard library ● The "Batteries" include: ○ Robust HTTP Web Server + template library ○ Compression, encryption, JSON / XML / CSV ○ Profiling, debugging, source parsing ○ Reflection library ○ Image manipulation ○ Plus the usual suspects ○ No GUI Toolkit :)
  • 27. The standard library: A Web Server package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!" , r.URL.Path[1:]) } func main() { http.HandleFunc( "/", handler) http.ListenAndServe( ":8080", nil) }
  • 28. Reason 8: C is never too far ● CGo is part of the standard library ● Makes binding C libraries trivial ● You can also trivially call Go code from C ● BTW: A JVM based Go exists ;) package rand /* #include <stdlib.h> */ import "C" func Random() int { return int(C.rand()) } func Seed(i int) { C.srand(C. uint(i)) }
  • 29. Reason 9: Implicit Interfaces ● Implementing an interface simply means you implement it, no declaration needed. ● Example: any struct that has a method String() string can be used for "%s" fmt ● You can mix and match interfaces as you go ● The empty interface, interface{} is super useful. ● Interfaces can be safely cast into structs, or called directly.
  • 30. Reason 10: Procrastination It's Fun! ● Go is fun to work on and read about ● Beware: productive procrastination :) ● "Code is compiling" is no longer valid! ● Thank God we have a new excuse
  • 31. Before we get too excited ● Lack of complete, real IDE ● Debugging: GDB Works great - but no real frontend ● No dynamic linking/loading ● Implicit interfaces are cool but can be confusing ● No exceptions - a matter of taste.
  • 32. Wanna write some Go code? We're hiring! :) We're introducing Go to our backend and data crunching stack, where C++ used to roam, or where Go could kick Python's ass. Email jobs@everything.me
  • 33. A Few Good Resources ● The official website: http://golang.org/ ● Excellent introductory book: http://www.golang-book.com/ ● GoDoc: Package search http://godoc.org/ ● Migrating from Python to Go: http://blog.repustate.com/migrating-code-from-python- to-golang-what-you-need-to-know/2013/04/23/