1 option
Learning Functional Programming in Go : Function Literals, Monads, Lazy Evaluation, Currying, and More.
- Format:
- Book
- Author/Creator:
- Sheehan, Lex.
- Language:
- English
- Subjects (All):
- Go (Computer program language).
- Physical Description:
- 1 online resource (665 pages)
- Edition:
- 1st ed.
- Place of Publication:
- Birmingham : Packt Publishing, Limited, 2017.
- Biography/History:
- Sheehan Lex: Lex Sheehan has a B. S. in Computer Science from Auburn University, resides in Atlanta, GA, and works as a senior software engineer with over 20 years of experience. He has a deep understanding of functional programming (FP). After using FP techniques in Ruby, Scala, JavaScript, Haskell, and Java, and writing an article about FP in Go, he decided it was time to write a book about it. Lex worked for IBM Software Group and IBM Global Business Services, designing and building various enterprise business systems. He is the author of eight US patents (IT security and data transformations) and he writes a blog titled Application Development with Lex Sheehan. Lex has turned his attention to distributed systems programming and crypto economics. He is currently leveraging his background in Go and passion for blockchain technologies to build a privacy layer for the Ethereum (and other) blockchains. Lex is available to consult and meet with your CTO and/or provide in-house training on the information in this book and related technologies.
- Contents:
- Cover
- Title Page
- Copyright
- Credits
- About the Author
- Acknowledgments
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: Pure Functional Programming in Go
- Motivation for using FP
- Getting the source code
- The directory structure of the source files
- How to run our first Go application
- Imperative versus declarative programming
- Pure functions
- Fibonacci sequence - a simple recursion and two performance improvements
- Memoization
- The difference between an anonymous function and a closure
- FP using Go's concurrency constructs
- Testing FP using test-driven development
- A note about paths
- How to run our tests
- A journey from imperative programming to pure FP and enlightenment
- Benchmark test for the imperative SumLoop function
- Benchmark test for the SumRecursive function
- A time of reckoning
- A quick example of a function literal
- Summary
- Chapter 2: Manipulating Collections
- Iterating through a collection
- Piping Bash commands
- Functors
- Functions that modify functions
- A coding example of functions that modify functions
- A visual example of functions that modify functions
- Composition in Mindcraft
- Tacit programming
- Tacit programming with Unix pipes
- Programming CMOS with Unix pipes
- Tacit programming with FP
- Non-TCO recursive example
- TCO recursive example
- The importance of recursion
- Various intermediate and terminal functions
- Reduce example
- Intermediate functions
- Common intermediate functions
- Map Example
- Terminal functions
- Common terminal functions
- Join example
- GroupBy example
- Predicates
- Reflection
- Combinator pattern
- Map and filter
- Contains
- Iterating over a collection of cars
- The empty interface
- The Contains() method.
- If Go had generics
- Map function
- Testing our empty interface-based Map function
- Itertools
- Go channels used by the New function
- Testing itertool's Map function
- Testing iterators for element equality
- Functional packages
- Another time of reflection
- Go is awesome
- Go is awesome, but
- The cure
- Gleam - distributed MapReduce for Golang
- LuaJIT's FFI library
- Unix pipe tools
- Processing Gleam collections
- Chapter 3: Using High-Order Functions
- Characteristics of FP
- Function composition
- Monads allow us to chain continuations
- Generics
- First-class functions
- Closure
- Dynamically scoped
- Pure function
- Immuable Data
- Persistent data structures for Go
- Use of expressions
- Sample HOF application
- The chapter4 application code
- Build and runtime instructions
- More application code
- The Filter function
- Reality check
- FilterFunc
- Filter function
- RESTful resources
- Chaining functions
- More cars
- The Map function
- Improved performance from the Map function
- The Reduce function
- More high-order functions
- Generators
- RESTful server
- The GenerateCars function
- Currying Goroutine
- A closer look at currying
- Extending our currying example
- Using a WaitGroup variable to manage concurrency
- Finishing up the GenerateCars function
- Handling concurrency
- The final HOF example
- Chapter 4: SOLID Design in Go
- Why many Gophers eschew Java
- More reasons for eschewing Java
- Digging deeper into error handling
- Software design methodology
- Good design
- Bad design
- Good versus bad design over time
- SOLID design principles
- Single responsibility principle
- Open/closed principle
- Open / close principle in functional programming
- FantasyLand JavaScript specification
- Setoid algebra.
- Ord algebra
- The expression problem
- Liskov substitution principle
- This OOP method stinks
- Our FP function smells like roses
- In FP, contracts don't lie
- Duck typing
- What can go wrong with inheritance?
- Interface segregation principle
- Dependency inversion principle
- The big reveal
- MapReduce
- MapReduce example
- What else can Monads do?
- Viva La Duck
- Pass by value or reference?
- Type embedding with Go interfaces
- Interface embedding to add minor features
- A Go error handling idiom
- It's time to run our program
- Chapter 5: Adding Functionality with Decoration
- Interface composition
- Go's complimentary Reader and Writer interfaces
- Example usages of the Reader and Writer interfaces
- Design with Duck Typing
- More reasons to design using interfaces
- Using the Reader and Writer interfaces
- Decorator pattern
- Type hierarchy UML
- How Procedural design compares to functional Inversion of Control (IoC)
- Procedural design example
- Functional IoC example
- A decorator implementation
- The main.go file
- The decorator/simple_log.go file
- Example InitLog calls
- Back to our main package
- Understanding our statistics using the easy-metrics GUI
- Quick look at the Dot Init update
- Easy-metrics - 1 of 3
- The decorator/decorator.go file
- A framework to inject dependencies
- Wrapping a client request with decorators (in main)
- Authorization decorator
- Logging decorator
- LoadBalancing decorator
- Strategy pattern
- Inversion of control and dependency injection
- Our first failure
- Easy metrics - 2 of 3
- Groking our trace log file
- The rest of the graph
- Easy metrics - 3 of 3
- Examining the trace log
- The decorator/requestor.go file
- The job variable declared in main()
- Back to the requestor.go file
- Using channels to manage the life cycle.
- All requests done
- Launching our makeRequest goroutine
- Our DI framework in action
- Chapter 6: Applying FP at the Architectural Level
- Application architectures
- What is software architecture?
- Client-server architecture
- Cloud architecture
- Why does architecture matter?
- The role of systems engineering
- Real systems
- IT system specialty groups
- Systems engineering is lean
- Requirements, scope and terms
- Defining terms
- Software requirements
- System
- System architecture
- System elements
- System Boundaries
- Managing Complexity
- The best tool for the job
- Divide and conquer
- Designing for state management
- Add a microservice
- FP influenced architectures
- Domain Driven Design
- Dependency rule
- Cyclic dependency
- Working code
- Code with cyclic dependency error
- The Golang difference
- Solution for cyclic dependencies
- Interface-driven development
- Hollywood principle
- Observer pattern
- Dependency injection
- A cloud bucket application
- Directory structure
- main.go
- func HandlePanic
- func main()
- Layers in the architecture
- Domain layer
- Use cases layer
- Compatible interfaces
- Interfaces layer
- Why global variables are bad
- Format the response
- Testing our interfaces
- Infrastructure layer
- Context object
- Benefits of DDD
- Adaptability
- Sustainability
- Testability
- Comprehensibility
- A solid architectural foundation
- FP and Micyoservices
- Message passing
- All parties must participate
- Communication across boundaries
- Polyglot Persistence
- Lambda architecture
- Speed
- Batch
- Servicing
- Next generation big data architecture
- CQRS
- Benefits of CQRS
- Infrastructure architecture
- Share nothing architecture
- Integrating services
- Agreed upon protocol.
- Circuit breakers
- Functional reactive architecture
- Go is ideal for building microservices
- Size matters
- Benefits of gRPC
- Who is using Go?
- Chapter 7: Functional Parameters
- Refactoring long parameter lists
- What's wrong with a function signature with more than seven parameters?
- Refactoring - the book
- Edsger W. Dijkstra says OOP is a bad idea
- What else did Edsger W. Dijkstra say?
- The underlying OOP problem
- OOP inconsistency
- Functional programming and cloud computing
- A closer look at f(x)
- A closer look at refactoring
- Passing every parameter a function requires to do its job is not a good idea
- Methods can query other objects' methods internally for data required to make decisions
- Methods should depend on their host class for needed data
- Pass a whole object with required attributes to reduce the number of required parameters
- Replace parameter with method technique to reduce the number of required parameters
- Before applying Replace Parameter with Method technique
- After applying Replace Parameter with Method technique
- Use a parameter object when we have unrelated data elements to pass
- Long parameter lists will change over time and are inherently difficult to understand
- The solution
- Three ways to pass multiple parameters
- Simply passing multiple parameters
- Passing a configuration object/struct that contains multiple attributes
- Partial application
- Functional parameters
- Contexts
- Context limitations
- Report example
- Writing good code is not unlike a good game of soccer
- Functional parameters - Rowe
- A more practical Context use case
- src/server/server.go
- The src/server/server_options.go file
- Chapter 8: Increasing Performance Using Pipelining
- Introducing the pipeline pattern
- Grep sort example.
- Pipeline characteristics.
- Notes:
- Description based on publisher supplied metadata and other sources.
- ISBN:
- 1-78728-604-5
- OCLC:
- 1013744613
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.