Date post: | 13-Apr-2017 |
Category: |
Software |
Upload: | michal-konarski |
View: | 327 times |
Download: | 0 times |
GOLANG VS RUBYMICHAŁ KONARSKI
1
2
0,75%
1,5%
2,25%
3%
2012 2013 2014 2015 2016 2017
3
POPULARITY OF GO
0,75%
1,5%
2,25%
3%
2012 2013 2014 2015 2016 2017
source: http://www.tiobe.com/tiobe-index/go/
WHO AM I? 4
u2i
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
STATICALLY TYPED DUCK TYPING
8
9typeAnimalinterface{Speak()string
}
typeDogstruct{ageint32
}
func(dDog)Speak()string{return"Woof!"
}
funcSaySomething(aAnimal){ fmt.Println(a.Speak())}
dog:=Dog{}SaySomething(dog)
000 DESIGN
10
11Vehicle
Car Truck
PetrolCar PetrolTruck
ElectricCar ElectricTruck
COMPOSITION OVER INHERITANCE
12
13
Vehicle
Engine
Body
PetrolEngine
ElectricEngine
Car
Truck
14
typeEngineinterface{start()}
typePetrolEnginestruct{}typeElectricEnginestruct{}
typeBodyinterface{weight()int32}
typeCarstruct{}typeTruckstruct{}
typeVehiclestruct{EngineBody}
vehicle:=Vehicle{Engine:PetrolEngine{},Body:Truck{}}vehicle.start()vehicle.weight()
CONCURRENCY
15
DON'T COMMUNICATE BY SHARING MEMORY, SHARE MEMORY BY COMMUNICATING.
16
channel
channel
channel
17
Go process
goroutine goroutine
goroutine goroutine
goroutine goroutine
18
result:=<-ch
funcHeavyComputations(){...
}
ch<-result
chchanint32
ch:=make(chanint32)
goHeavyComputations(ch)
//dootherthings
19
THERE IS NOTHING EXCEPTIONAL IN EXCEPTIONS
20
iferr!=nil{log.Fatal(err)returnerr
}
f,err:=os.Open(“filename.ext")
//dosomethingwiththefile
21
GO FMT NO MORE CODE STYLE WARS
22
“LEARN AT LEAST ONE NEW LANGUAGE EVERY YEAR”
23
David Thomas and Andrew Hunt