small medium large xlarge

Functional Programming: A PragPub Anthology: Exploring Clojure, Elixir, Haskell, Scala, and Swift

by

Cover image for Functional Programming: A PragPub Anthology

Functional Programming: A PragPub Anthology

Exploring Clojure, Elixir, Haskell, Scala, and Swift

by

Explore functional programming and discover new ways of thinking about code. You know you need to master functional programming, but learning one functional language is only the start. In this book, through articles drawn from PragPub magazine and articles written specifically for this book, you’ll explore functional thinking and functional style and idioms across languages. Led by expert guides, you’ll discover the distinct strengths and approaches of Clojure, Elixir, Haskell, Scala, and Swift and learn which best suits your needs.

Choose Your Format(s)

  • $25.95 In Stock
    • Beta: What do I get?

  • Ebooks are DRM free.

  • Ebook delivery options.

  • The Paper Book will ship on 2017-10-10 (roughly).

About this Title

Skill-meter-4-8
Pages: 250 (est)
Published: 2017-10-10
Release: B1.0 (2017-05-16)
ISBN: 978-1-68050-233-6

Functional programming is on the rise because it lets you write simpler, cleaner code, and its emphasis on immutability makes it ideal for maximizing the benefits of multiple cores and distributed solutions. So far nobody’s invented the perfect functional language—each has its unique strengths. In Functional Programming: A PragPub Anthology, you’ll investigate the philosophies, tools, and idioms of five different functional programming languages.

See how Swift, the development language for iOS, encourages you to build highly scalable apps using functional techniques like map and reduce. Discover how Scala allows you to transition gently but deeply into functional programming without losing the benefits of the JVM, while with Lisp-based Clojure, you can plunge fully into the functional style. Learn about advanced functional concepts in Haskell, a pure functional language making powerful use of the type system with type inference and type classes. And see how functional programming is becoming more elegant and friendly with Elixir, a new functional language built on the powerful Erlang base.

The industry has been embracing functional programming more and more, driven by the need for concurrency and parallelism. This collection of articles will lead you to mastering the functional approach to problem solving. So put on your explorer’s hat and prepare to be surprised. The goal of exploration is always discovery.

What You Need

Familiarity with one or more programming languages.

Contents & Extracts

This book is currently in beta, so the contents and extracts will change as the book is developed.

Introduction

  • The Functional Paradigm
    • Functional Programming Is Big Again
      • We’ve Seen This Movie Before
      • New Arguments for Functional Programming
    • Functional Thinking For The Imperative Mind
      • It’s About Functions
      • It’s About Immutability
      • It’s a Way of Thinking
  • Scala: a Hybrid Language
    • Scala and Functional Style
      • Functional Purity
      • Higher-Order Functions
      • A Simple Example
      • A Practical Example
      • What About Debugging and Performance?
    • Working with Scala Collections
      • Immutable Collections
      • Mutable Collections
      • Lazy Collections
    • Creating Higher Order Functions in Scala
      • Creating a Higher-Order Function
      • Multiple Parameter Lists
      • Function Values and the Loan Pattern
  • Clojure: the New Lisp
    • An Interview with Rich Hickey
      • Why Clojure?
      • The Infrastructure
      • Compared to What?
    • Getting Clojure: Why Lisp Still Matters
      • The REPL
      • Vectors and Keywords
      • Macros
    • Identity, Value, and State in Clojure
      • The Object-Oriented Model
      • The Clojure Model
    • Concurrent Programming in Clojure
      • A “Simple” Concurrent Programming Problem
      • Clojure’s Solution
  • Elixir: Making Programming Fun Again
    • Patterns and Transformations in Elixir
      • Pattern Matching
      • Pattern Matching Structured Data
      • Pattern Matching and Functions
      • Transformation Is Job #1
    • Getting Functional with Elixir
      • Anonymous Functions
      • Named Functions
      • A Practical Example
      • Refactor to Functional Style
      • What’s Different About this Code
    • Getting Parallel with Elixir
      • The Actor Model
      • Actors and Elixir
      • Messages
      • Monitoring Your Processes
      • A Final Example
      • Concurrency is the Core of Elixir
  • Haskell: The Researcher’s Playground
    • Functional Thinking and Haskell
      • What It’s all About
      • A Quick Exercise
      • Data Types Are Cheap
      • Pattern Matching
      • Recursion, Control, and Higher Order Functions
      • Further Features
    • Haskell Hands-on
      • One Step at a Time
      • Generating Candidates
      • Dictionary Filtering
      • Breadth-first Searching
      • Using the Search
      • Performance and Optimization
  • Swift: Functional Programming for Mobile Apps
    • Swift: What You Need to Know
      • Hello, Swift!
      • Functional Swift
    • Functional Thinking in Swift
      • Avoid Nil, Unless You Mean It
      • Avoid Mutable State
      • Use Higher-Order Functions
  • Going Deeper
    • Protocols in Swift vs. Ruby and Elixir
      • The Problem with Extensions
      • The Case for Protocols
      • Protocols and Extensions
    • Pattern Matching in Scala
      • Counting Coins
      • Matching All the Things
      • Using Extractions
    • Concurrency in Scala
      • Using Parallel Collections
      • Knowing when to Use Concurrency
      • Revisiting an Earlier Example
    • Clojure’s Exceptional Handling of Exceptions
      • A Simple Example
      • The Problem with Exceptions
      • A Solution: Conditions
      • Make Life Simple For Your Callers
      • Laziness and Errors
    • A Testing Framework for Elixir
      • Investing in Testing
      • One Experiment, Several Measurements
      • Optimizing Setup with TrueStory
      • Condense and Combine the Measurements
      • Controlling Setup Repetition with Nested Contexts
      • Controlling Setup Repetition with Story Pipes
    • Building Test Data with Elixir
      • The Typical Approaches
      • Beautiful Data for Beautiful Tests
      • Registering Templates and Prototypes with Forge
      • Instantiating Template Entries
      • Mutual Attributes and Having
      • Creating Structs
      • Creating Custom Entities
      • Customizing Persistence
    • Haskell’s Type System
      • TL;DR
      • What Are Types For?
      • A Concrete Example: Sorting
      • The Language of Haskell’s Type System
      • Type Inference and Type Checking
      • Some Examples
      • Comfort Break
      • Interfaces and Type Classes
      • Some Real-world Examples with Interfaces
      • Pros and Cons — the 80-20 Rule
      • Beyond Haskell: Dependent Types
      • Propositions are Types, and Proofs are Programs
      • Another Look at Sorting
      • Back to Earth
    • A Haskell Project: Testing Native Code
      • Our Native Code
      • Our Model
      • A Brief Introduction to Haskell’s FFI
      • Wrapping our Native Code in Haskell
      • Experimenting with GHCi
      • A Brief Introduction to QuickCheck
      • Writing an Equivalence Property
      • Defect Smashing
    • The Many Faces of Swift Functions
      • Anatomy of Swift Functions
      • Calling All Functions
      • Calling on Methods
      • Instance Methods Are Curried Functions
      • Init: A Special Note
      • Fancy Parameters
      • Access Controls
      • Fancy Return Types
      • Nested Functions
    • A Functional Approach to Lua
      • First-Class Functions in Lua
      • Recursion in Lua
      • Building with Functional Primitives
      • A Simple Game Animation

Author

The authors are all recognized experts in functional programming and languages. Rich Hickey created the Clojure language, Stuart Halloway and Aaron Bedra wrote Programming Clojure, Michael Bevilacqua-Linn wrote Functional Programming Patterns in Scala and Clojure, Venkat Subramaniam wrote Pragmatic Scala, Paul Callaghan lectures on Haskell and functional programming, José Valim created Elixir, Dave Thomas wrote Programming Elixir, Natasha (the Robot) Murashev is a leading authority on Swift, Tony Hillerson was an early Swift adopter, Josh Chisholm is a Lua expert, and Bruce Tate has written numerous books on programming languages. Michael Swaine is the former editor of Dr. Dobb’s Journal, current editor of PragPub magazine, and co-author of Fire in the Valley: the Birth and Death of the Personal Computer.