Introduction to Go programming language from PHP engineer's perspective.
The topic was presented at GetYourGuide’s internal tech talk. The original article can be found here: http://sobit.me/2016/02/25/go-from-php-engineers-perspective/
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Go from PHP engineer's perspective
1. GO FROM PHP ENGINEER’S
PERSPECTIVE
SOBIT AKHMEDOV
2. GO FROM PHP ENGINEER’S PERSPECTIVE
PHP FRAMEWORKS
▸ Symfony
▸ Laravel
▸ Zend Framework
3. GO FROM PHP ENGINEER’S PERSPECTIVE
PHP TOOLS AND COMMUNITY
▸ Composer
▸ Monolog
▸ PHP-FIG
4. GO FROM PHP ENGINEER’S PERSPECTIVE
THEY STARTED WITH PHP
▸ Facebook
▸ Yahoo!
▸ Wikipedia
▸ Wordpress
▸ Tumblr
5. GO FROM PHP ENGINEER’S PERSPECTIVE
PHP AND MICROSERVICES
▸ Good response time on single application only ✓
▸ Good for WEB development ✓
▸ Bad for microservices architectures: ✗
▸ Timeout handling ✗
▸ Metrics collection ✗
▸ Bulkheads ✗
▸ Circuit breakers ✗
7. GO (OFTEN REFERRED TO AS GOLANG) IS AN OPEN SOURCE
PROGRAMMING LANGUAGE DEVELOPED AT GOOGLE IN 2007 BY ROBERT
GRIESEMER, ROB PIKE, AND KEN THOMPSON. DESIGNED PRIMARILY FOR
SYSTEMS PROGRAMMING, IT IS A COMPILED, STATICALLY TYPED
LANGUAGE IN THE TRADITION OF C AND C++, WITH GARBAGE
COLLECTION, VARIOUS SAFETY FEATURES AND CSP-STYLE
CONCURRENT PROGRAMMING FEATURES ADDED.
Wikipedia
GO FROM PHP ENGINEER’S PERSPECTIVE
8. GO FROM PHP ENGINEER’S PERSPECTIVE
MEET GO
▸ Developed at Google in 2007
▸ Due to the frustration of dealing with the complexity
▸ Announced in November 2009
▸ Special feature: extreme simplicity
▸ Go: 25 keywords
▸ PHP: 67 keywords
9. GO FROM PHP ENGINEER’S PERSPECTIVE
BUILT WITH GO
▸ Docker
▸ Kubernetes
▸ etcd
▸ InfluxDb
10.
11. GO FROM PHP ENGINEER’S PERSPECTIVE
GO AND MICROSERVICES
▸ Fast compilation
▸ Parallel execution
▸ Transport protocols
▸ JSON over HTTP, gRPC, Protocol Buffers, Thrift
▸ Request tracing in Zipkin
▸ Metrics exporting to statsd, Prometheus, etc.
▸ Rate limiters
▸ … others
13. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ Strictly typed
▸ Type inference
14. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ Multiple return types
15. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ Multiple return types
16. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No foreach, no while, no do-while
17. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No foreach, no while, no do-while
18. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No foreach, no while, no do-while
19. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No foreach, no while, no do-while
20. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No classes, only structs
21. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ No classes, only structs
22. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ Goroutine — a function executing concurrently with other
goroutines in the same address space
▸ Exits silently on completion
23. GO FROM PHP ENGINEER’S PERSPECTIVE
LANGUAGE
▸ Goroutine are “fire-and-forget”
▸ Channels - if we need the result
24. GO FROM PHP ENGINEER’S PERSPECTIVE
TOOLS
▸ go fmt
▸ go doc
▸ go vet
▸ go test
▸ go get github.com/hoisie/redis
▸ … others
25. GO FROM PHP ENGINEER’S PERSPECTIVE
DEPLOYING PHP APPLICATION (BASIC)
▸ Checkout the latest code on the target server into a new
release folder
▸ Copy cached dependencies and install updated ones
▸ Copy environment-specific configuration files
▸ Run all the scripts to warm the application up
▸ Point the current release symlink into the new release folder
▸ Restart PHP-FPM
26. GO FROM PHP ENGINEER’S PERSPECTIVE
DEPLOYING PHP APPLICATION (ADVANCED)
▸ Checkout the latest code on the build server
▸ “Build” it (install dependencies, warm the caches up, etc.)
▸ Create a distributable “artifact” (an archived tar.gz file)
▸ Transfer the artifact to the target server
▸ Unarchive into a new release folder
▸ Point the current release symlink into the new release folder
▸ Restart PHP-FPM
27. GO FROM PHP ENGINEER’S PERSPECTIVE
DEPLOYING GO APPLICATION
▸ Checkout the latest code on the build server
▸ Build it (note the absence of quotes)
▸ Transfer the artifact (again no quotes) to the target server
▸ Restart the running application
28. GO FROM PHP ENGINEER’S PERSPECTIVE
DEPLOYING GO APPLICATION
▸ No need to install Go on target servers
▸ Builds for different OS and architectures
▸ From single machine
▸ Even for Windows!
30. GO FROM PHP ENGINEER’S PERSPECTIVE
CONCLUSION
▸ Premature decomposition = failure
▸ PHP fits monolithic application strategy
▸ Building microservices with PHP is painful
▸ Consider Go
▸ Easier than Java or Scala
▸ Performance is not far behind C
31. GO FROM PHP ENGINEER’S PERSPECTIVE
HOW CAN I CONTINUE?
▸ Learn: https://golang.org/doc/#learning
▸ Learn more: https://github.com/golang/go/wiki/Learn
▸ IDEs: https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins
▸ https://github.com/go-lang-plugin-org/go-lang-idea-plugin
▸ Go kit: https://github.com/go-kit/kit
▸ Client-side Go: http://www.gopherjs.org/
▸ Go for mobile apps: https://github.com/golang/go/wiki/Mobile