SlideShare a Scribd company logo
1 of 40
1 / 40
Do I need to switch
to Go(lang)
Max Tepkeev
20 July 2016
Bilbao, Spain
2 / 40
About me
Max Tepkeev
Russia, Moscow
• python-redmine
• architect
• instructions
https://www.github.com/maxtepkeev
3 / 40
About us
Aidata – online and
offline user data
collection and analysis
1 000 000 000
unique users per month
http://www.aidata.me
4 / 40
About us
5 / 40
Why switch from Python
• Speed
• Concurrency
• GIL
• No ”true” binaries
• Dynamic types
6 / 40
Language requirements
• Modern
• Fast
• Easy
• Compiled
• Statically typed
• Support main platforms
7 / 40
Why Go
StackOverflow questions by tag*:
• Go: 16795 (1113)
• Rust: 4226 (429)
• D: 2025 (34)
• Nim: 136 (8)
* as of 19 July 2016
8 / 40
Popularity
9 / 40
Go
• Created in Google
• Open-sourced in November 2009
• Designed by smart people:
• Robert Griesemer
• Rob Pike
• Ken Thompson
https://talks.golang.org/2012/splash.article
10 /
Who uses Go
• Google
• Dropbox
• Facebook
• IBM
• Intel
• SpaceX
• Uber
• VMware
• Yahoo
• Twitter
• Heroku
• DigitalOcean
https://github.com/golang/go/wiki/GoUsers
11 / 40
Project layout
$GOPATH/
bin/
hello # command executable
outyet # command executable
pkg/
linux_amd64/
github.com/golang/example/
stringutil.a # package object
src/
github.com/golang/example/
.git/ # Git repository metadata
hello/
hello.go # command source
outyet/
main.go # command source
stringutil/
reverse.go # package source
12 /
Package management
$ go get github.com/golang/example
src/
github.com/golang/example/
.git/
hello/
hello.go
outyet/
main.go
stringutil/
reverse.go
13 /
Package management
• vendoring
• gopkg.in
• getgb.io
github.com/tools/godep
github.com/gpmgo/gopm
github.com/pote/gpm
github.com/nitrous-io/goop
github.com/alouche/rodent
github.com/jingweno/nut
github.com/niemeyer/gopkg
github.com/mjibson/party
github.com/kardianos/vendor
github.com/kisielk/vendorize
github.com/mattn/gom
github.com/dkulchenko/bunch
github.com/skelterjohn/wgo
github.com/Masterminds/glide
github.com/robfig/glock
bitbucket.org/vegansk/gobs
launchpad.net/godeps
github.com/d2fn/gopack
github.com/laher/gopin
github.com/LyricalSecurity/gigo
github.com/VividCortex/johnny-deps
14 /
Commands
• go fmt
• go test
• go fix
• go run
• go run -race
• go vet
15 /
Hello World
$GOPATH/src/github.com/user/hello/hello.go:
package main
import "fmt"
func main() {
fmt.Println("Hello, world.")
}
$ go install github.com/user/hello
$ $GOPATH/bin/hello
Hello, world.
16 /
Comparison: Imports
Go
import "os"
import (
"os"
"compress/gzip"
)
import os1 "os"
Python
import os
import os
import gzip
import os as os1
17 /
Comparison: Import Names
Go
import "os"
os.Getwd()
Python
import os
os.getcwd()
18 /
Comparison: Types
Go
var (
b bool = true
s string = "hey"
si int = -1
ui uint = 1
f float32 = 1.0
c complex64 = 3i
l []int = []int{1, 2}
m map[int]int = map[int]int{1: 1}
)
Python
b = True
s = "hey"
si = 1
ui = -1
f = 1.0
c = 3j
l = [1, 2]
m = {1:1}
19 /
Comparison: Variables
Go
var (
i = 1
j = "hey"
)
i := 1
j := "hey”
i, j := 1, "hey"
Python
i = 1
j = "hey”
i, j = 1, "hey"
20 /
Comparison: 1st Class Functions
Go
func add(x, y int) int {
return x + y
}
add := func (x, y int) int {
return x + y
}
Python
def add(x, y):
return x + y
add = lambda x, y: x + y
21 /
Comparison: Optional args
Go
func sum(nums ...int) {
result := 0
for _, num := range nums {
result += num
}
return result
}
sum(1, 2, 3)
sum([]int{1, 2, 3}...)
Python
def sum(*nums):
result = 0
for num in nums:
result += num
return result
sum(1, 2, 3)
sum(*[1, 2, 3])
22 /
Comparison: Optional kwargs
Go
type Kwargs struct {
foo, bar string
}
func join(kw Kwargs) string {
if kw.foo == "" {kw.foo = "foo"}
if kw.bar == "" {kw.bar = "bar"}
return kw.foo + kw.bar
}
join(Kwargs{})
join(Kwargs{bar: "foo"})
Python
def join(foo=None, bar=None):
if foo is None:
foo = 'foo'
if bar is None:
bar = 'bar'
return foo + bar
join()
join(bar='foo')
23 /
Comparison: Loops
Go
seq := []int{1, 2, 3}
for _, x := range seq {
fmt.Println(x)
}
Python
seq = [1, 2, 3]
for x in seq:
print x
24 /
Comparison: Loops
Go
seq := []int{1, 2, 3}
for i := 0; i < len(seq); i++ {
fmt.Println(seq[i])
}
Python
seq = [1, 2, 3]
num, count = 0, len(seq)
while num < count:
print seq[num]
num += 1
25 /
Comparison: Loops
Go
for {
fmt.Println("Go rocks")
}
Python
while True:
print "Python rocks"
26 /
Comparison: Comprehensions
Go
word := "hello"
chars := []string{}
for _, char := range word {
chars = append(chars, string(char))
}
fmt.Println(chars) // [h e l l o]
Python
word = "hello"
chars = [char for char in word]
print chars # ['h', 'e', 'l', 'l', 'o']
27 /
Comparison: Conditionals
Go
if x := 1; x > 0 {
fmt.Println(x)
} else {
fmt.Println("Sorry")
}
Python
x = 1
if x > 0:
print x
else:
print "Sorry"
28 /
Comparison: Conditionals
Go
switch x := 1; {
case x < 0:
fmt.Println("Negative")
case x > 0:
fmt.Println("Positive")
default:
fmt.Println("Zero")
}
Python
x = 1
if x > 0:
print "Positive"
elif x < 0:
print "Negative"
else:
print "Zero"
29 /
Comparison: Slicing
Go
seq := []int{1, 2, 3, 4, 5}
fmt.Print(seq[:2]) // [1 2]
fmt.Print(seq[3:]) // [4 5]
fmt.Print(seq[2:3]) // [3]
Python
seq = [1, 2, 3, 4, 5]
print seq[:2] # [1, 2]
print seq[3:] # [4, 5]
print seq[2:3] # [3]
30 /
Comparison: Error Handling
Go
conn, err := db.Connect()
if err != nil {
fmt.Print("Can't connect")
}
panic() / recover()
Python
try:
conn = db.Connect()
except ConnectionError:
print "Can't connect"
31 /
Comparison: Classes
Go
type Person struct {
Name string
Age int
}
func (p Person) String() string {
return fmt.Sprintf(
"%s: %d", p.Name, p.Age)
}
p := Person{"Batman", 45}
fmt.Println(p) // Batman: 45
Python
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return "{}: {}".format(
self.name, self.age)
p = Person("Batman", 45)
print p # Batman: 45
32 /
Comparison: Constructors
Go
type Person struct {
Name string
Age int
}
func NewPerson(n string, a int) *Person {
return &Person{Name: n, Age: a}
}
p := NewPerson("Batman", 45)
Python
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
p = Person("Batman", 45)
33 /
Comparison: Inheritance
Go
type Person struct{ Name string }
type Doctor struct{ Person }
func (p Person) Eat() {
fmt.Println("Eating")
}
func (d Doctor) Heal() {
fmt.Println("Healing")
}
d := Doctor{Person{"Gregory House"}}
d.Eat() // Eating
d.Heal() // Healing
Python
class Person(object):
def __init__(self, name):
self.name = name
def eat(self):
print "Eating"
class Doctor(Person):
def heal(self):
print "Healing"
d = Doctor("Gregory House")
d.eat() # "Eating"
d.heal() # "Healing"
34 /
Comparison: Cleanup
Go
func readFile() (result string) {
fpath := "/tmp/file"
f, err := os.Open(fpath)
if err != nil {
panic(err)
}
defer f.Close()
// reading file here
return result
}
Python
def read_file():
result = None
fpath = "/tmp/file"
with open(fpath) as f:
result = f.read()
# file is closed here
return result
35 /
Comparison: Concurrent progs
Go
urls := []string{"http://python.org",
"http://golang.org"}
responses := make(chan string)
for _, url := range urls {
go func(url string) {
resp, _ := http.Get(url)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
responses <- string(body)
}(url)
}
for response := range responses {
fmt.Println(response)
}
Python
urls = ['http://python.org', 'http://golang.org']
async def fetch(session, url):
async with session.get(url) as response:
return await response.read()
async def fetch_all(session, urls, loop):
tasks = [fetch(session, url) for url in urls]
return await asyncio.gather(*tasks)
loop = asyncio.get_event_loop()
with aiohttp.ClientSession(loop=loop) as session:
responses = loop.run_until_complete(
fetch_all(session, urls, loop))
print(responses)
36 /
More Go features
• make() / new()
• Arrays
• Pointers
• Interfaces
• Type assertions
• Type switches
• Buffered channels / select statement
• Unsafe package
• Cross compilation
37 /
Python features Go lacks
• list / dict comprehensions
• generators
• decorators
• exceptions
• metaclasses
• descriptors
• __magic__ methods
• set / tuple
38 /
Conclusion
Go
+ Good standard library
+ 3rd Party libs for almost everything
+ Compiled
+ Statically typed
+ Built-in concurrency
- Verbose
- No syntactic sugar
- No Soul
Python
+ Good standard library
+ 3rd Party libs for everything
+ Less code
+ Syntactic sugar
+ Has Soul
- Interpreted
- Dynamically typed
- Concurrency
39 /
Go Useful Links
1. https://tour.golang.org/
2. http://golang.org/doc/effective_go.html
3. https://play.golang.org/
4. http://golangweekly.com/
5. http://devs.cloudimmunity.com/gotchas-
and-common-mistakes-in-go-golang/
40 /
Questions
slides: http://slideshare.net/maxtepkeev
github: https://github.com/maxtepkeev
email: tepkeev@gmail.com
skype: max.tepkeev
company: http://www.aidata.me

More Related Content

What's hot

PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...Maulik Borsaniya
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan Osman
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialRomin Irani
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Fariz Darari
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text ProcessingRodrigo Senra
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windowsextremecoders
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonMax Klymyshyn
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Garth Gilmour
 
The Arrow Library in Kotlin
The Arrow Library in KotlinThe Arrow Library in Kotlin
The Arrow Library in KotlinGarth Gilmour
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)Steven Francia
 
7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid themSteven Francia
 
Python 3000
Python 3000Python 3000
Python 3000Bob Chao
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)Subhas Kumar Ghosh
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better JavaGarth Gilmour
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekingeProf. Wim Van Criekinge
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Samuel Lampa
 

What's hot (20)

PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop Material
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
Python basic
Python basicPython basic
Python basic
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windows
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and Python
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
 
The Arrow Library in Kotlin
The Arrow Library in KotlinThe Arrow Library in Kotlin
The Arrow Library in Kotlin
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
 
7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them
 
Python 3000
Python 3000Python 3000
Python 3000
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
 
Python ppt
Python pptPython ppt
Python ppt
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
 

Similar to EuroPython 2016 - Do I Need To Switch To Golang

Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewMarkus Schneider
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
Go programming introduction
Go programming introductionGo programming introduction
Go programming introductionGinto Joseph
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONvikram mahendra
 
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
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshersrajkamaltibacademy
 
Something about Golang
Something about GolangSomething about Golang
Something about GolangAnton Arhipov
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologiesit-people
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxSahajShrimal1
 
Python for Scientific Computing
Python for Scientific ComputingPython for Scientific Computing
Python for Scientific ComputingAlbert DeFusco
 

Similar to EuroPython 2016 - Do I Need To Switch To Golang (20)

Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / Overview
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
Go programming introduction
Go programming introductionGo programming introduction
Go programming introduction
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
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#
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshers
 
Let's golang
Let's golangLet's golang
Let's golang
 
A Tour of Go - Workshop
A Tour of Go - WorkshopA Tour of Go - Workshop
A Tour of Go - Workshop
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Python crush course
Python crush coursePython crush course
Python crush course
 
Python Part 1
Python Part 1Python Part 1
Python Part 1
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
 
Python for Scientific Computing
Python for Scientific ComputingPython for Scientific Computing
Python for Scientific Computing
 

More from Max Tepkeev

EuroPython 2017 - How to make money with your Python open-source project
EuroPython 2017 - How to make money with your Python open-source projectEuroPython 2017 - How to make money with your Python open-source project
EuroPython 2017 - How to make money with your Python open-source projectMax Tepkeev
 
EuroPython 2015 - Big Data with Python and Hadoop
EuroPython 2015 - Big Data with Python and HadoopEuroPython 2015 - Big Data with Python and Hadoop
EuroPython 2015 - Big Data with Python and HadoopMax Tepkeev
 
EuroPython 2015 - Instructions
EuroPython 2015 - InstructionsEuroPython 2015 - Instructions
EuroPython 2015 - InstructionsMax Tepkeev
 
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIEuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIMax Tepkeev
 
EuroPython 2014 - Architect
EuroPython 2014 - ArchitectEuroPython 2014 - Architect
EuroPython 2014 - ArchitectMax Tepkeev
 
PyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoPyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoMax Tepkeev
 

More from Max Tepkeev (6)

EuroPython 2017 - How to make money with your Python open-source project
EuroPython 2017 - How to make money with your Python open-source projectEuroPython 2017 - How to make money with your Python open-source project
EuroPython 2017 - How to make money with your Python open-source project
 
EuroPython 2015 - Big Data with Python and Hadoop
EuroPython 2015 - Big Data with Python and HadoopEuroPython 2015 - Big Data with Python and Hadoop
EuroPython 2015 - Big Data with Python and Hadoop
 
EuroPython 2015 - Instructions
EuroPython 2015 - InstructionsEuroPython 2015 - Instructions
EuroPython 2015 - Instructions
 
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGIEuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
 
EuroPython 2014 - Architect
EuroPython 2014 - ArchitectEuroPython 2014 - Architect
EuroPython 2014 - Architect
 
PyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoPyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with Django
 

Recently uploaded

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 

Recently uploaded (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 

EuroPython 2016 - Do I Need To Switch To Golang

  • 1. 1 / 40 Do I need to switch to Go(lang) Max Tepkeev 20 July 2016 Bilbao, Spain
  • 2. 2 / 40 About me Max Tepkeev Russia, Moscow • python-redmine • architect • instructions https://www.github.com/maxtepkeev
  • 3. 3 / 40 About us Aidata – online and offline user data collection and analysis 1 000 000 000 unique users per month http://www.aidata.me
  • 5. 5 / 40 Why switch from Python • Speed • Concurrency • GIL • No ”true” binaries • Dynamic types
  • 6. 6 / 40 Language requirements • Modern • Fast • Easy • Compiled • Statically typed • Support main platforms
  • 7. 7 / 40 Why Go StackOverflow questions by tag*: • Go: 16795 (1113) • Rust: 4226 (429) • D: 2025 (34) • Nim: 136 (8) * as of 19 July 2016
  • 9. 9 / 40 Go • Created in Google • Open-sourced in November 2009 • Designed by smart people: • Robert Griesemer • Rob Pike • Ken Thompson https://talks.golang.org/2012/splash.article
  • 10. 10 / Who uses Go • Google • Dropbox • Facebook • IBM • Intel • SpaceX • Uber • VMware • Yahoo • Twitter • Heroku • DigitalOcean https://github.com/golang/go/wiki/GoUsers
  • 11. 11 / 40 Project layout $GOPATH/ bin/ hello # command executable outyet # command executable pkg/ linux_amd64/ github.com/golang/example/ stringutil.a # package object src/ github.com/golang/example/ .git/ # Git repository metadata hello/ hello.go # command source outyet/ main.go # command source stringutil/ reverse.go # package source
  • 12. 12 / Package management $ go get github.com/golang/example src/ github.com/golang/example/ .git/ hello/ hello.go outyet/ main.go stringutil/ reverse.go
  • 13. 13 / Package management • vendoring • gopkg.in • getgb.io github.com/tools/godep github.com/gpmgo/gopm github.com/pote/gpm github.com/nitrous-io/goop github.com/alouche/rodent github.com/jingweno/nut github.com/niemeyer/gopkg github.com/mjibson/party github.com/kardianos/vendor github.com/kisielk/vendorize github.com/mattn/gom github.com/dkulchenko/bunch github.com/skelterjohn/wgo github.com/Masterminds/glide github.com/robfig/glock bitbucket.org/vegansk/gobs launchpad.net/godeps github.com/d2fn/gopack github.com/laher/gopin github.com/LyricalSecurity/gigo github.com/VividCortex/johnny-deps
  • 14. 14 / Commands • go fmt • go test • go fix • go run • go run -race • go vet
  • 15. 15 / Hello World $GOPATH/src/github.com/user/hello/hello.go: package main import "fmt" func main() { fmt.Println("Hello, world.") } $ go install github.com/user/hello $ $GOPATH/bin/hello Hello, world.
  • 16. 16 / Comparison: Imports Go import "os" import ( "os" "compress/gzip" ) import os1 "os" Python import os import os import gzip import os as os1
  • 17. 17 / Comparison: Import Names Go import "os" os.Getwd() Python import os os.getcwd()
  • 18. 18 / Comparison: Types Go var ( b bool = true s string = "hey" si int = -1 ui uint = 1 f float32 = 1.0 c complex64 = 3i l []int = []int{1, 2} m map[int]int = map[int]int{1: 1} ) Python b = True s = "hey" si = 1 ui = -1 f = 1.0 c = 3j l = [1, 2] m = {1:1}
  • 19. 19 / Comparison: Variables Go var ( i = 1 j = "hey" ) i := 1 j := "hey” i, j := 1, "hey" Python i = 1 j = "hey” i, j = 1, "hey"
  • 20. 20 / Comparison: 1st Class Functions Go func add(x, y int) int { return x + y } add := func (x, y int) int { return x + y } Python def add(x, y): return x + y add = lambda x, y: x + y
  • 21. 21 / Comparison: Optional args Go func sum(nums ...int) { result := 0 for _, num := range nums { result += num } return result } sum(1, 2, 3) sum([]int{1, 2, 3}...) Python def sum(*nums): result = 0 for num in nums: result += num return result sum(1, 2, 3) sum(*[1, 2, 3])
  • 22. 22 / Comparison: Optional kwargs Go type Kwargs struct { foo, bar string } func join(kw Kwargs) string { if kw.foo == "" {kw.foo = "foo"} if kw.bar == "" {kw.bar = "bar"} return kw.foo + kw.bar } join(Kwargs{}) join(Kwargs{bar: "foo"}) Python def join(foo=None, bar=None): if foo is None: foo = 'foo' if bar is None: bar = 'bar' return foo + bar join() join(bar='foo')
  • 23. 23 / Comparison: Loops Go seq := []int{1, 2, 3} for _, x := range seq { fmt.Println(x) } Python seq = [1, 2, 3] for x in seq: print x
  • 24. 24 / Comparison: Loops Go seq := []int{1, 2, 3} for i := 0; i < len(seq); i++ { fmt.Println(seq[i]) } Python seq = [1, 2, 3] num, count = 0, len(seq) while num < count: print seq[num] num += 1
  • 25. 25 / Comparison: Loops Go for { fmt.Println("Go rocks") } Python while True: print "Python rocks"
  • 26. 26 / Comparison: Comprehensions Go word := "hello" chars := []string{} for _, char := range word { chars = append(chars, string(char)) } fmt.Println(chars) // [h e l l o] Python word = "hello" chars = [char for char in word] print chars # ['h', 'e', 'l', 'l', 'o']
  • 27. 27 / Comparison: Conditionals Go if x := 1; x > 0 { fmt.Println(x) } else { fmt.Println("Sorry") } Python x = 1 if x > 0: print x else: print "Sorry"
  • 28. 28 / Comparison: Conditionals Go switch x := 1; { case x < 0: fmt.Println("Negative") case x > 0: fmt.Println("Positive") default: fmt.Println("Zero") } Python x = 1 if x > 0: print "Positive" elif x < 0: print "Negative" else: print "Zero"
  • 29. 29 / Comparison: Slicing Go seq := []int{1, 2, 3, 4, 5} fmt.Print(seq[:2]) // [1 2] fmt.Print(seq[3:]) // [4 5] fmt.Print(seq[2:3]) // [3] Python seq = [1, 2, 3, 4, 5] print seq[:2] # [1, 2] print seq[3:] # [4, 5] print seq[2:3] # [3]
  • 30. 30 / Comparison: Error Handling Go conn, err := db.Connect() if err != nil { fmt.Print("Can't connect") } panic() / recover() Python try: conn = db.Connect() except ConnectionError: print "Can't connect"
  • 31. 31 / Comparison: Classes Go type Person struct { Name string Age int } func (p Person) String() string { return fmt.Sprintf( "%s: %d", p.Name, p.Age) } p := Person{"Batman", 45} fmt.Println(p) // Batman: 45 Python class Person(object): def __init__(self, name, age): self.name = name self.age = age def __str__(self): return "{}: {}".format( self.name, self.age) p = Person("Batman", 45) print p # Batman: 45
  • 32. 32 / Comparison: Constructors Go type Person struct { Name string Age int } func NewPerson(n string, a int) *Person { return &Person{Name: n, Age: a} } p := NewPerson("Batman", 45) Python class Person(object): def __init__(self, name, age): self.name = name self.age = age p = Person("Batman", 45)
  • 33. 33 / Comparison: Inheritance Go type Person struct{ Name string } type Doctor struct{ Person } func (p Person) Eat() { fmt.Println("Eating") } func (d Doctor) Heal() { fmt.Println("Healing") } d := Doctor{Person{"Gregory House"}} d.Eat() // Eating d.Heal() // Healing Python class Person(object): def __init__(self, name): self.name = name def eat(self): print "Eating" class Doctor(Person): def heal(self): print "Healing" d = Doctor("Gregory House") d.eat() # "Eating" d.heal() # "Healing"
  • 34. 34 / Comparison: Cleanup Go func readFile() (result string) { fpath := "/tmp/file" f, err := os.Open(fpath) if err != nil { panic(err) } defer f.Close() // reading file here return result } Python def read_file(): result = None fpath = "/tmp/file" with open(fpath) as f: result = f.read() # file is closed here return result
  • 35. 35 / Comparison: Concurrent progs Go urls := []string{"http://python.org", "http://golang.org"} responses := make(chan string) for _, url := range urls { go func(url string) { resp, _ := http.Get(url) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) responses <- string(body) }(url) } for response := range responses { fmt.Println(response) } Python urls = ['http://python.org', 'http://golang.org'] async def fetch(session, url): async with session.get(url) as response: return await response.read() async def fetch_all(session, urls, loop): tasks = [fetch(session, url) for url in urls] return await asyncio.gather(*tasks) loop = asyncio.get_event_loop() with aiohttp.ClientSession(loop=loop) as session: responses = loop.run_until_complete( fetch_all(session, urls, loop)) print(responses)
  • 36. 36 / More Go features • make() / new() • Arrays • Pointers • Interfaces • Type assertions • Type switches • Buffered channels / select statement • Unsafe package • Cross compilation
  • 37. 37 / Python features Go lacks • list / dict comprehensions • generators • decorators • exceptions • metaclasses • descriptors • __magic__ methods • set / tuple
  • 38. 38 / Conclusion Go + Good standard library + 3rd Party libs for almost everything + Compiled + Statically typed + Built-in concurrency - Verbose - No syntactic sugar - No Soul Python + Good standard library + 3rd Party libs for everything + Less code + Syntactic sugar + Has Soul - Interpreted - Dynamically typed - Concurrency
  • 39. 39 / Go Useful Links 1. https://tour.golang.org/ 2. http://golang.org/doc/effective_go.html 3. https://play.golang.org/ 4. http://golangweekly.com/ 5. http://devs.cloudimmunity.com/gotchas- and-common-mistakes-in-go-golang/
  • 40. 40 / Questions slides: http://slideshare.net/maxtepkeev github: https://github.com/maxtepkeev email: tepkeev@gmail.com skype: max.tepkeev company: http://www.aidata.me