SlideShare a Scribd company logo
1 of 24
THE BEST FEATURE OF GO
A 5-YEAR RETROSPECTIVE
GO & I
▸ Programming since the ‘90s
▸ Former C, C++, PHP, Python, JavaScript, Java programmer
▸ Switched to Go in 2012
▸ Handful of large Go implementations across 2 companies
▸ Have my own shortlist of favorite Go features over the years
▸ One of those features is exceptional
NOTABLE FEATURES
COMPILER & SYNTAX
▸ Avoids historically error prone constructs
▸ Highly assistive error messages
▸ Focus on intention rather than expression
▸ If it compiles, it mostly works
▸ Very high performance with low effort
SMALL FEATURE SET
▸ A tad bigger than C
▸ Orthogonal, Minimal
▸ Easy to Learn
▸ Easy to Remember
▸ Minimized Personal Feature Subsets
STANDARDIZED FORMATTING
▸ 10
x improvement in readability
▸ Improved collaboration between team members
▸ Improved collaboration across teams
▸ More easily accessible Open Source code
SENSIBLE UNICODE & STRINGS
▸ UTF-8 encoded strings
▸ Compatible []byte and string memory layout
▸ Minimized copying between buffers and strings
▸ Rich set of string manipulators available
GOROUTINES & CHANNELS
▸ Declarative Parallel Programming
▸ Based on CSP Principles
▸ Straight-forward procedural logic — no callback mess
▸ Any function/method can be invoked asynchronously
SELECT STATEMENT
▸ Go’s tour de force in parallel programming
▸ Simple, declarative expression of event synchronization
▸ Makes previously complicated flows trivial to implement
▸ Timeouts
▸ Cancellation
▸ Back-pressure handling
▸ Combinations of the above
CAPABILITY
GO CHANGED MY PROGRAMMING
PERFORMANCE AND COMPLEXITY WITH CONFIDENCE
▸ First production system in Go: a Multiplayer Game Engine
▸ Made > $1000,000 in a year
▸ Also, a rate limiter, a reverse proxy, a micro-service simulator,
deployment orchestrator, cluster auto-scaler…
▸ … even a bespoke datastore!
PROGRAMMER
ONE FEATURE CHANGED ME AS A
THE BEST FEATURE OF GO
▸ Acts as a stand-in for the user
▸ Improves documentation
▸ Guides program design
▸ Aids Refactoring & Debugging
▸ Finds unnecessary/dysfunctional code
▸ Gives rapid feedback on performance characteristics
Can you guess what it is?
GO TEST
GO TEST IN DESIGN PHASE
USER SIMULATION
Use package pkg_test to get “3rd Party” view
▸ Allows accessing your package like an end-user
▸ Helps the provider switch mind to that of a consumer
▸ Helps in deciding exported symbols
▸ Improves API Design
GO TEST IN DESIGN PHASE
DOCUMENTATION
▸ Write testable, runnable Examples that show up in the
documentation
▸ Document methods: func ExampleStruct_Method() {…}
▸ Document functions: func ExampleFunction() {…}
▸ Document use cases: func Example_useCase() {…}
GO TEST IN DESIGN PHASE
PROGRAM DESIGN
▸ Monolithic do-it-all functions are hard to test
▸ The need to test improves modularity, functional cohesion
▸ Sample Strategy:
1. Implement business logic as native APIs with native data — test
entire business logic
2. Implement data load/store from native to database — test data
validation and access
3. Implement remoting (HTTP etc.) APIs — test request interpretation
and response serialization
GO TEST IN IMPLEMENTATION PHASE
REFACTORING
▸ Table driven testing helps in basic I/O validation
▸ Top-level tests for checking various scenarios
▸ Subtests help in isolating granular functionality
▸ Non-compilable tests indicate changes in package interface
▸ Failing tests indicate changes in functional behaviours
GO TEST IN IMPLEMENTATION PHASE
DEBUGGING
▸ Parallel tests with race detector for
unsafe concurrent data access
▸ Optional long running tests for
deeper verification
▸ Test cases can be complex enough
to act as simulators. 



E.g. the graph here is from a 1-
million iteration sim of smartcb
Error Rate Learned Rate SmartCB Regular CB
GO TEST IN IMPLEMENTATION PHASE
FINDING USELESS CODE
▸ $ go test -coverprofile to find which lines were executed
by the test
▸ Untouched lines =>
▸ The tests don’t check the logic for which the code is written,
or
▸ The code is untestable because it’s dead or represents a
logically impossible scenario
GO TEST IN OPTIMIZATION PHASE
BENCHMARKING
▸ $ go test -bench to see how fast functions/methods are
▸ $ go test -bench -cpu to observe multi-core scalability
▸ $ go test -bench -cpuprofile to see what parts of the
code are slow
▸ $ go test -bench -memprofile to see what parts of the
code eat up memory
▸ Run go test -bench before every commit to find
performance regressions
GO TEST IS LIKE A PROGRAMMER’S
ASSISTANT. AN IRONMAN’S JARVIS. A
BATMAN’S ALFRED.
IT HAPPENS TO RUN UNIT TESTS TOO
Yours Truly
MORE THAN UNIT TESTING
THANK YOU
TAHIR HASHMI, PT TOKOPEDIA, JAN 2018
FURTHER INFORMATION
▸ talks.golang.org
▸ tour.golang.org
▸ tech.t9i.in
▸ @code_martial

More Related Content

Similar to The Best Feature of Go – A 5 Year Retrospective

FT 2009 Highspeed Test Automation
FT 2009 Highspeed Test AutomationFT 2009 Highspeed Test Automation
FT 2009 Highspeed Test Automation
Michel Löhr
 

Similar to The Best Feature of Go – A 5 Year Retrospective (20)

FT 2009 Highspeed Test Automation
FT 2009 Highspeed Test AutomationFT 2009 Highspeed Test Automation
FT 2009 Highspeed Test Automation
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Developer-friendly task queues: what we learned building MRQ, Sylvain Zimmer
Developer-friendly task queues: what we learned building MRQ, Sylvain ZimmerDeveloper-friendly task queues: what we learned building MRQ, Sylvain Zimmer
Developer-friendly task queues: what we learned building MRQ, Sylvain Zimmer
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 
The Mechanics of Testing Large Data Pipelines
The Mechanics of Testing Large Data PipelinesThe Mechanics of Testing Large Data Pipelines
The Mechanics of Testing Large Data Pipelines
 
Be DevOps Ready
Be DevOps ReadyBe DevOps Ready
Be DevOps Ready
 
Devops (start walking in the same direction) by ops
Devops (start walking in the same direction) by opsDevops (start walking in the same direction) by ops
Devops (start walking in the same direction) by ops
 
The Popper Experimentation Protocol and CLI tool
The Popper Experimentation Protocol and CLI toolThe Popper Experimentation Protocol and CLI tool
The Popper Experimentation Protocol and CLI tool
 
Andrea Di Persio
Andrea Di PersioAndrea Di Persio
Andrea Di Persio
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
Modern day jvm controversies
Modern day jvm controversiesModern day jvm controversies
Modern day jvm controversies
 
CIlib 2.0: Rethinking Implementation
CIlib 2.0: Rethinking ImplementationCIlib 2.0: Rethinking Implementation
CIlib 2.0: Rethinking Implementation
 
Measuring Your Code
Measuring Your CodeMeasuring Your Code
Measuring Your Code
 
Measuring Your Code 2.0
Measuring Your Code 2.0Measuring Your Code 2.0
Measuring Your Code 2.0
 
Intro to DevOps
Intro to DevOpsIntro to DevOps
Intro to DevOps
 
Continuous Testing With React Storybook & WebdriverIO
Continuous Testing With React Storybook & WebdriverIOContinuous Testing With React Storybook & WebdriverIO
Continuous Testing With React Storybook & WebdriverIO
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
 
Technical Practices for Agile Engineering - PNSQC 2019
Technical Practices for Agile Engineering - PNSQC 2019Technical Practices for Agile Engineering - PNSQC 2019
Technical Practices for Agile Engineering - PNSQC 2019
 
A Java Developers first Clojure project
A Java Developers first Clojure projectA Java Developers first Clojure project
A Java Developers first Clojure project
 
Full stack development best practice and toolset
Full stack development best practice and toolsetFull stack development best practice and toolset
Full stack development best practice and toolset
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

The Best Feature of Go – A 5 Year Retrospective

  • 1. THE BEST FEATURE OF GO A 5-YEAR RETROSPECTIVE
  • 2. GO & I ▸ Programming since the ‘90s ▸ Former C, C++, PHP, Python, JavaScript, Java programmer ▸ Switched to Go in 2012 ▸ Handful of large Go implementations across 2 companies ▸ Have my own shortlist of favorite Go features over the years ▸ One of those features is exceptional
  • 4. COMPILER & SYNTAX ▸ Avoids historically error prone constructs ▸ Highly assistive error messages ▸ Focus on intention rather than expression ▸ If it compiles, it mostly works ▸ Very high performance with low effort
  • 5. SMALL FEATURE SET ▸ A tad bigger than C ▸ Orthogonal, Minimal ▸ Easy to Learn ▸ Easy to Remember ▸ Minimized Personal Feature Subsets
  • 6. STANDARDIZED FORMATTING ▸ 10 x improvement in readability ▸ Improved collaboration between team members ▸ Improved collaboration across teams ▸ More easily accessible Open Source code
  • 7. SENSIBLE UNICODE & STRINGS ▸ UTF-8 encoded strings ▸ Compatible []byte and string memory layout ▸ Minimized copying between buffers and strings ▸ Rich set of string manipulators available
  • 8. GOROUTINES & CHANNELS ▸ Declarative Parallel Programming ▸ Based on CSP Principles ▸ Straight-forward procedural logic — no callback mess ▸ Any function/method can be invoked asynchronously
  • 9. SELECT STATEMENT ▸ Go’s tour de force in parallel programming ▸ Simple, declarative expression of event synchronization ▸ Makes previously complicated flows trivial to implement ▸ Timeouts ▸ Cancellation ▸ Back-pressure handling ▸ Combinations of the above
  • 11. PERFORMANCE AND COMPLEXITY WITH CONFIDENCE ▸ First production system in Go: a Multiplayer Game Engine ▸ Made > $1000,000 in a year ▸ Also, a rate limiter, a reverse proxy, a micro-service simulator, deployment orchestrator, cluster auto-scaler… ▸ … even a bespoke datastore!
  • 13. THE BEST FEATURE OF GO ▸ Acts as a stand-in for the user ▸ Improves documentation ▸ Guides program design ▸ Aids Refactoring & Debugging ▸ Finds unnecessary/dysfunctional code ▸ Gives rapid feedback on performance characteristics Can you guess what it is?
  • 15. GO TEST IN DESIGN PHASE USER SIMULATION Use package pkg_test to get “3rd Party” view ▸ Allows accessing your package like an end-user ▸ Helps the provider switch mind to that of a consumer ▸ Helps in deciding exported symbols ▸ Improves API Design
  • 16. GO TEST IN DESIGN PHASE DOCUMENTATION ▸ Write testable, runnable Examples that show up in the documentation ▸ Document methods: func ExampleStruct_Method() {…} ▸ Document functions: func ExampleFunction() {…} ▸ Document use cases: func Example_useCase() {…}
  • 17. GO TEST IN DESIGN PHASE PROGRAM DESIGN ▸ Monolithic do-it-all functions are hard to test ▸ The need to test improves modularity, functional cohesion ▸ Sample Strategy: 1. Implement business logic as native APIs with native data — test entire business logic 2. Implement data load/store from native to database — test data validation and access 3. Implement remoting (HTTP etc.) APIs — test request interpretation and response serialization
  • 18. GO TEST IN IMPLEMENTATION PHASE REFACTORING ▸ Table driven testing helps in basic I/O validation ▸ Top-level tests for checking various scenarios ▸ Subtests help in isolating granular functionality ▸ Non-compilable tests indicate changes in package interface ▸ Failing tests indicate changes in functional behaviours
  • 19. GO TEST IN IMPLEMENTATION PHASE DEBUGGING ▸ Parallel tests with race detector for unsafe concurrent data access ▸ Optional long running tests for deeper verification ▸ Test cases can be complex enough to act as simulators. 
 
 E.g. the graph here is from a 1- million iteration sim of smartcb Error Rate Learned Rate SmartCB Regular CB
  • 20. GO TEST IN IMPLEMENTATION PHASE FINDING USELESS CODE ▸ $ go test -coverprofile to find which lines were executed by the test ▸ Untouched lines => ▸ The tests don’t check the logic for which the code is written, or ▸ The code is untestable because it’s dead or represents a logically impossible scenario
  • 21. GO TEST IN OPTIMIZATION PHASE BENCHMARKING ▸ $ go test -bench to see how fast functions/methods are ▸ $ go test -bench -cpu to observe multi-core scalability ▸ $ go test -bench -cpuprofile to see what parts of the code are slow ▸ $ go test -bench -memprofile to see what parts of the code eat up memory ▸ Run go test -bench before every commit to find performance regressions
  • 22. GO TEST IS LIKE A PROGRAMMER’S ASSISTANT. AN IRONMAN’S JARVIS. A BATMAN’S ALFRED. IT HAPPENS TO RUN UNIT TESTS TOO Yours Truly MORE THAN UNIT TESTING
  • 23. THANK YOU TAHIR HASHMI, PT TOKOPEDIA, JAN 2018
  • 24. FURTHER INFORMATION ▸ talks.golang.org ▸ tour.golang.org ▸ tech.t9i.in ▸ @code_martial