why should every ruby developer learn golang?

26
WHY SHOULD EVERY RUBY DEVELOPER LEARN GOLANG? MICHAŁ KONARSKI 1

Upload: michal-konarski

Post on 13-Apr-2017

60 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Why should every Ruby developer learn Golang?

WHY SHOULD EVERY RUBY DEVELOPER LEARN GOLANG?MICHAŁ KONARSKI

1

Page 2: Why should every Ruby developer learn Golang?

2

0,75%

1,5%

2,25%

3%

2012 2013 2014 2015 2016 2017

Page 3: Why should every Ruby developer learn Golang?

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

Page 4: Why should every Ruby developer learn Golang?

WHO AM I? 4

u2i.com

Ruby developer @

Page 5: Why should every Ruby developer learn Golang?

5

Page 6: Why should every Ruby developer learn Golang?

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

Page 7: Why should every Ruby developer learn Golang?

7

dynamic

interpreted (MRI)

static

compiled

object oriented

reflective concurrent

structured

garbage collected garbage collected

Page 8: Why should every Ruby developer learn Golang?

8

NoMethodError:

undefined method `retweets' for #<FacebookPost>

Page 9: Why should every Ruby developer learn Golang?

STATICALLY TYPED DUCK TYPING

9

Page 10: Why should every Ruby developer learn Golang?

10typeAnimalinterface{Speak()string

}

typeDogstruct{ageint32

}

func(dDog)Speak()string{return"Woof!"

}

funcSaySomething(aAnimal){ fmt.Println(a.Speak())}

dog:=Dog{}SaySomething(dog)

Page 11: Why should every Ruby developer learn Golang?

A STORY OF OO DESIGN

11

Page 12: Why should every Ruby developer learn Golang?

12Vehicle

Car Truck

PetrolCar PetrolTruck

ElectricCar ElectricTruck

Page 13: Why should every Ruby developer learn Golang?

COMPOSITION OVER INHERITANCE

13

Page 14: Why should every Ruby developer learn Golang?

14

Vehicle

Engine

Body

PetrolEngine

ElectricEngine

CarBody

TruckBody

Page 15: Why should every Ruby developer learn Golang?

15

typeEngineinterface{start()}

typeBodyinterface{weight()int32}

typeVehiclestruct{EngineBody}

vehicle:=Vehicle{Engine:PetrolEngine{},Body:TruckBody{}}vehicle.start()vehicle.weight()

typePetrolEnginestruct{}typeElectricEnginestruct{}

typeCarBodystruct{}typeTruckBodystruct{}

Page 16: Why should every Ruby developer learn Golang?

CONCURRENCY

16

Page 17: Why should every Ruby developer learn Golang?

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

Page 18: Why should every Ruby developer learn Golang?

18

a=Thread.new{semaphore.synchronize{#accesssharedresource}}

require'thread'semaphore=Mutex.new

b=Thread.new{semaphore.synchronize{#accesssharedresource}}

Page 19: Why should every Ruby developer learn Golang?

DON'T COMMUNICATE BY SHARING MEMORY, SHARE MEMORY BY COMMUNICATING.

19

Page 20: Why should every Ruby developer learn Golang?

channel

channel

channel

20

Go process

goroutine goroutine

goroutine goroutine

goroutine goroutine

Page 21: Why should every Ruby developer learn Golang?

21

result:=<-ch

funcHeavyComputations(){...

}

ch<-result

chchanint32

ch:=make(chanint32)

goHeavyComputations(ch)

//dootherthings

Page 22: Why should every Ruby developer learn Golang?

22

THERE IS NOTHING EXCEPTIONAL IN EXCEPTIONS

Page 23: Why should every Ruby developer learn Golang?

23

iferr!=nil{fmt.Println(err)returnerr

}

f,err:=os.Open(“filename.ext")

//dosomethingwiththefile

Page 24: Why should every Ruby developer learn Golang?

24

Page 25: Why should every Ruby developer learn Golang?

“LEARN AT LEAST ONE NEW LANGUAGE EVERY YEAR”

25

David Thomas and Andrew Hunt

Page 26: Why should every Ruby developer learn Golang?

26

@mjkonarski [email protected]

u2i.com

THANKS!