Golang from  Scala   developer’s  perspective
About  me Svetlana  Bozhko Backend  Scala  Developer  @  Adform
The  goal Is  Go  really  so  bad imperative?
Content Short  intro  into  Go Tooling   FP  vs.  Go IMHO
Usage https://github.com/golang/go/wiki/GoUsers
How  to  start? http://tour.golang.org/ http://golangshow.com/
Go Good  parts
Go  is  actually  a  pretty   simple  language!
Even  too  simple  for  2015
Advanced  GC
“Build  time  matters  more   than  anything  else”  -­‐ Rob  Pike
gofmt
Quite  good  tools build-­‐in  (version,  get,  build,  …) editors  (vim,  intellij,  sublime,  …)
Concurrency • Channels send  data  between  threads  easily,   asynchronously  or  synchronously • GoRoutines spin  up  another  thread,  just  like  that!
No  Language  Is  Perfect...
Go  Mentality • Smallest  possible  feature  set • It’s  okay  to  copy  some  code   • Productivity  instead  of  hyper-­‐elegant  code
Let’s  get  rid  of • Implicit  numeric  conversion  (int !=  int32) • ‘Implements’  keyword • ‘Classes’ • Constructor/destructor • Function  overloading • Pointer  arithmetic   • Exceptions  and  try/catch • Generics • …
Strict  compiler which  interrupts  you  sometimes
Wait,  Go  has  ‘goto’?
Wait,  how  to  debug? GDB,  but  it’s  not  very  good  way
Dependency   management vendor  (since  1.5)  
FP  vs.  Go
Wikipedia: “Functional  programming is  a programming  paradigm   — a  style  of  building  the  structure  and  elements  of   computer  programs  — that  treats computation as  the   evaluation  of mathematical  functions and  avoids   changing-­‐state and mutable data.”  
What  it  means? No  mutable  data  (no  side  effect) No  mutable  state  (no  implicit,  hidden  state) Same  result  returned  by  functions  called  with  the  same  inputs Functions  are  pure  functions  in  the  mathematical  sense
Advantages? Cleaner  code Referential  transparency
Referential  transparency Memoization Cache  results Idempotence Modularization We  have  no  state Ease  of  debugging Functions  are  isolated  and  very  easy  to  debug
Referential  transparency Parallelization Functions  calls  are  independent   We  can  parallelize  in  different  process/CPUs/computers/...   res  =  func1(a,  b)  +  func2(a,  c)
Referential  transparency With  no  shared  data,  concurrencygets  a  lot  simpler: No  semaphores No  monitors   No  locks No  race-­‐conditions No  dead-­‐locks
Nonetheless Golang has  built-­‐in  “sync”  package  with  mutexes
Don’t  Update,  Create!
String
Arrays
Maps
Higher  order  functions
FP  libraries https://github.com/yanatan16/itertools https://github.com/tobyhede/go-­‐underscore
Higher  order  functions
Map
Filter
Reduce
Closures
Currying  and  Partial   Functions
Eager  vs  Lazy  Evaluation Golang channels  and  goroutines enable  the   creation  of  generators  that  could  be  a  way  to  have   lazy  evaluation
Recursion
FP  &  OOP It  is  possible  do  FP  in  OOP?   Yes  it  is! OOP  is  orthogonal  to  FP.  At  least  in  theory…
Exercise! What  is  the  sum  of  the  first  10  natural  number   whose  square  value  is  divisible  by  2?
Exercise! Imperative Functional
Learn  at  least  one   functional  language It  will  open  your  mind  to  a  new  paradigm   becoming  you  a  better  programmer
Conclusion Technologies  are  awesome!   The  problem  is  people how  we  use  them.
Thank  you! Questions? Svetlana  Bozhko aka  @SBozhko http://devzen.ru/ svt.bozhko@gmail.com
Links https://golang-­‐ru.slack.com/messages https://www.youtube.com/watch?list=PLPHSBhlVt TyfwIKn7r_a5xkzzMu-­‐iey-­‐w&v=cGXorQkw3JE

Golang from Scala developer’s perspective