SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Coding with golang
Coding with golangCoding with golang
Coding with golang
 
Go Programming Language by Google
Go Programming Language by GoogleGo Programming Language by Google
Go Programming Language by Google
 
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventure
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
Golang #5: To Go or not to Go
Golang #5: To Go or not to GoGolang #5: To Go or not to Go
Golang #5: To Go or not to Go
 
Optimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest ApiOptimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest Api
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
 
Go lang
Go langGo lang
Go lang
 
Come With Golang
Come With GolangCome With Golang
Come With Golang
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golang
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golang
 
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Go Lang
Go LangGo Lang
Go Lang
 
Golang
GolangGolang
Golang
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?
 
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
ATO 2014 - So You Think You Know 'Go'? The Go Programming LanguageATO 2014 - So You Think You Know 'Go'? The Go Programming Language
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
 
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
 

Similar a Golang from Scala developer’s perspective

Similar a Golang from Scala developer’s perspective (20)

Golang introduction
Golang introductionGolang introduction
Golang introduction
 
Scaling applications with go
Scaling applications with goScaling applications with go
Scaling applications with go
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java Developers
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
 
Golang : A Hype or the Future?
Golang : A Hype or the Future?Golang : A Hype or the Future?
Golang : A Hype or the Future?
 
AddisDev Meetup ii: Golang and Flow-based Programming
AddisDev Meetup ii: Golang and Flow-based ProgrammingAddisDev Meetup ii: Golang and Flow-based Programming
AddisDev Meetup ii: Golang and Flow-based Programming
 
Golang
GolangGolang
Golang
 
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)iTHome Gopher Day 2017: What can Golang do?  (Using project 52 as examples)
iTHome Gopher Day 2017: What can Golang do? (Using project 52 as examples)
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Go. why it goes v2
Go. why it goes v2Go. why it goes v2
Go. why it goes v2
 
Golang nuts (by Nii Nai at DevCongress 2013)
Golang nuts (by Nii Nai at DevCongress 2013)Golang nuts (by Nii Nai at DevCongress 2013)
Golang nuts (by Nii Nai at DevCongress 2013)
 
Golang
GolangGolang
Golang
 
Golang workshop - Mindbowser
Golang workshop - MindbowserGolang workshop - Mindbowser
Golang workshop - Mindbowser
 
Why Go Lang?
Why Go Lang?Why Go Lang?
Why Go Lang?
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii Shapoval
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Golang from Scala developer’s perspective