A Practical Guide to Building Robust Concurrent Systems
Introduction: Why Learn Gleam?
- What This Book Covers
- How to Use This Book
- Prerequisites
- A Note on Tone and Approach
Chapter 1: Why Gleam? Philosophy, History and Ecosystem
- The Problem with Modern Programming
- Enter Gleam: A Language for Clarity and Reliability
- History and Origins
- Design Principles
- The Gleam Ecosystem Today
- Who Should Use Gleam and When
- Comparing Gleam with Related Languages
- Summary
Chapter 2: Getting Started: Installation, Tooling and Your First Project
- Installing Gleam and Prerequisites
- Understanding the Gleam Build Tool
- Project Structure and Configuration
- Your First Gleam Program
- Editor Setup and Development Experience
- Building and Running Your First Application End-to-End
Chapter 3: Language Fundamentals: Syntax, Types and Functions
- Program Structure and Module Basics
- Variables, Constants and Immutability
- Basic Types
- Type Inference and Explicit Annotations
- Functions: Definition, Calls and Arguments
- Expressions and Statements
- Summary
Chapter 4: Pattern Matching, Guards and Control Flow
- The Power of Pattern Matching
- Case Expressions and Exhaustive Matching
- Matching on Tuples, Lists and Custom Patterns
- Guards: Adding Conditions to Patterns
- Pipelines for Readable Data Flow
- Recursion as Control Flow
- Summary
Chapter 5: Data Structures and Custom Types
- Records: Named Fields and Structured Data
- Custom Types and Variants
- Generics: Writing Reusable Type-Safe Code
- The Result Type: Explicit Error Handling
- The Option Type: Handling Absence Safely
- Lists, Tuples, Strings and Dictionaries
- Summary
Chapter 6: Functional Programming in Gleam
- Functions as First-Class Values
- Higher-Order Functions
- Immutability and Its Consequences
- Pure Functions and Side Effects
- Function Composition and Pipeline Design
- Laziness vs Eager Evaluation in Gleam
- Summary
Chapter 7: Modules, Organization and Code Structure
- Module System Fundamentals
- Imports and Qualified Access
- Type Exports and Public Interfaces
- Project Structure for Growing Applications
- Code Organization Patterns
- Refactoring and Modularization Strategies
- Summary
Chapter 8: Error Handling and Robustness
- Philosophy of Explicit Errors
- Using Result for Recoverable Errors
- The Try Operator and Error Propagation
- Custom Error Types
- Panic and Unrecoverable Errors
- Building Fault-Tolerant Components
- Summary
Chapter 9: Concurrency on the BEAM: Processes, Messages and Actors
- The BEAM Runtime and Why It Matters
- Lightweight Processes in Gleam
- Message Passing: Send and Receive
- The Actor Pattern in Practice
- Building Concurrent Systems
- Concurrency Pitfalls and Best Practices
- Summary
Chapter 10: OTP Concepts and Production-Concurrent Design
- What Is OTP and Why Gleam Uses It
- Supervision Trees: Letting Things Crash
- Gen_Server in Gleam
- Fault Tolerance Design
- Distributed Applications on BEAM
- Building Resilient Systems: Putting It All Together
- Summary
Chapter 11: Interoperability: Erlang, Elixir and JavaScript
- Calling Erlang from Gleam
- Calling Gleam from Elixir
- Calling Elixir from Gleam
- JavaScript Compilation Target
- JavaScript Interoperability
- Polyglot BEAM Projects
- Platform-Specific Code and Conditional Compilation
- Summary
Chapter 12: The Ecosystem: Packages, Dependencies and Tooling
- Hex Package Manager and gleam add
- Creating and Publishing Your Own Package
- Dependency Management Best Practices
- The Gleam Build Tool Deep Dive
- Documentation Generation and Reading Docs
- Community Libraries and Ecosystem Survey
- Summary
Chapter 13: Testing, Debugging and Quality Assurance
- The Gleam Test Framework
- Writing Effective Tests
- Property-Based Testing
- Test Structure and Helpers
- Debugging Techniques
- Static Analysis and Linting
- Continuous Integration for Gleam Projects
- Summary
Chapter 14: Building Real Applications: Web Services, APIs and Data
- Web Frameworks in Gleam
- Building a RESTful JSON API
- Working with JSON
- Database Access
- Networking and HTTP Clients
- Complete Application Walkthrough Summary
- Summary
Chapter 15: Performance, Deployment and Production Operations
- Performance Characteristics of Gleam
- Memory Behavior and Optimization
- Profiling and Benchmarking
- Deployment Options
- Observability in Production
- Security Considerations
- Summary
Chapter 16: Advanced Patterns and Idiomatic Gleam
- Common Design Patterns in Gleam
- Domain Modeling with Custom Types
- Effect Systems and Managed Side Effects
- Macro Programming and Why Gleam Avoids Them
- Migration Strategies
- Building Maintainable Long-Term Gleam Systems
- Summary
Conclusion: The Future of Gleam and Your Journey Ahead
- Where Gleam Is Headed
- The BEAM Ecosystem’s Future Role
- Your Path Forward as a Gleam Developer
- Final Thoughts on Simplicity, Reliability and Joy in Programming
References
- Official Gleam Resources
- Language Design and History
- BEAM Runtime and OTP
- Standard Library
- Web Development and Frameworks
- Databases
- Testing and Tooling
- Deployment and Operations
- Community and Learning Resources
- Comparative and Analytical Sources
