Why should every Ruby developer learn Golang?
-
Upload
michal-konarski -
Category
Software
-
view
60 -
download
3
Transcript of Why should every Ruby developer learn Golang?
WHY SHOULD EVERY RUBY DEVELOPER LEARN GOLANG?MICHAŁ KONARSKI
1
2
0,75%
1,5%
2,25%
3%
2012 2013 2014 2015 2016 2017
3
source: http://www.tiobe.com/tiobe-index/go/
POPULARITY OF GO
0,75%
1,5%
2,25%
3%
2012 2013 2014 2015 2016 2017
WHO AM I? 4
u2i.com
Ruby developer @
5
RESERVED KEYWORDS 6
0
45
90
135
180
JAVASCRIPT C# C++ JAVA RUBY C GO
http://stackoverflow.com/questions/4980766/reserved-keywords-count-by-programming-language
7
dynamic
interpreted (MRI)
static
compiled
object oriented
reflective concurrent
structured
garbage collected garbage collected
8
NoMethodError:
undefined method `retweets' for #<FacebookPost>
STATICALLY TYPED DUCK TYPING
9
10typeAnimalinterface{Speak()string
}
typeDogstruct{ageint32
}
func(dDog)Speak()string{return"Woof!"
}
funcSaySomething(aAnimal){ fmt.Println(a.Speak())}
dog:=Dog{}SaySomething(dog)
A STORY OF OO DESIGN
11
12Vehicle
Car Truck
PetrolCar PetrolTruck
ElectricCar ElectricTruck
COMPOSITION OVER INHERITANCE
13
14
Vehicle
Engine
Body
PetrolEngine
ElectricEngine
CarBody
TruckBody
15
typeEngineinterface{start()}
typeBodyinterface{weight()int32}
typeVehiclestruct{EngineBody}
vehicle:=Vehicle{Engine:PetrolEngine{},Body:TruckBody{}}vehicle.start()vehicle.weight()
typePetrolEnginestruct{}typeElectricEnginestruct{}
typeCarBodystruct{}typeTruckBodystruct{}
CONCURRENCY
16
CONCURRENCY RELATED QUESTIONS ON STACK OVERFLOW 17
0
1750
3500
5250
7000
JAVA C# C++ PYTHON GO SCALA C PHP
http://stackoverflow.com/questions/tagged/concurrency
18
a=Thread.new{semaphore.synchronize{#accesssharedresource}}
require'thread'semaphore=Mutex.new
b=Thread.new{semaphore.synchronize{#accesssharedresource}}
DON'T COMMUNICATE BY SHARING MEMORY, SHARE MEMORY BY COMMUNICATING.
19
channel
channel
channel
20
Go process
goroutine goroutine
goroutine goroutine
goroutine goroutine
21
result:=<-ch
funcHeavyComputations(){...
}
ch<-result
chchanint32
ch:=make(chanint32)
goHeavyComputations(ch)
//dootherthings
22
THERE IS NOTHING EXCEPTIONAL IN EXCEPTIONS
23
iferr!=nil{fmt.Println(err)returnerr
}
f,err:=os.Open(“filename.ext")
//dosomethingwiththefile
24
“LEARN AT LEAST ONE NEW LANGUAGE EVERY YEAR”
25
David Thomas and Andrew Hunt