Leanpub Header

Skip to main content

Gleam in Depth

A Practical Guide to Building Robust Concurrent Systems

Gleam in Depth
This book is 100% completeLast updated on 2026-09-02

Build a strong foundation in Gleam and learn how to turn its simplicity into reliable, concurrent systems. From language basics and the BEAM to OTP, web development and deployment, this practical guide uses clear explanations and runnable examples to help you build software that is safe, scalable and ready for production.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
201
Pages
About

About

About the Book

Gleam is a modern functional programming language designed for building type-safe, scalable systems that run on the Erlang VM and JavaScript platforms. This book takes you from your first Gleam program to production-ready concurrent applications, covering the language fundamentals, the BEAM runtime, OTP patterns, web development, deployment, and advanced systems design through clear explanations and complete runnable examples.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

A Practical Guide to Building Robust Concurrent Systems

Introduction: Why Learn Gleam?

  1. What This Book Covers
  2. How to Use This Book
  3. Prerequisites
  4. A Note on Tone and Approach

Chapter 1: Why Gleam? Philosophy, History, and Ecosystem

  1. The Problem with Modern Programming
  2. Enter Gleam: A Language for Clarity and Reliability
  3. History and Origins
  4. Design Principles
  5. The Gleam Ecosystem Today
  6. Who Should Use Gleam and When
  7. Comparing Gleam with Related Languages
  8. Summary

Chapter 2: Getting Started: Installation, Tooling, and Your First Project

  1. Installing Gleam and Prerequisites
  2. Understanding the Gleam Build Tool
  3. Project Structure and Configuration
  4. Your First Gleam Program
  5. Editor Setup and Development Experience
  6. Building and Running Your First Application End-to-End

Chapter 3: Language Fundamentals: Syntax, Types, and Functions

  1. Program Structure and Module Basics
  2. Variables, Constants, and Immutability
  3. Basic Types
  4. Type Inference and Explicit Annotations
  5. Functions: Definition, Calls, and Arguments
  6. Expressions and Statements
  7. Summary

Chapter 4: Pattern Matching, Guards, and Control Flow

  1. The Power of Pattern Matching
  2. Case Expressions and Exhaustive Matching
  3. Matching on Tuples, Lists, and Custom Patterns
  4. Guards: Adding Conditions to Patterns
  5. Pipelines for Readable Data Flow
  6. Recursion as Control Flow
  7. Summary

Chapter 5: Data Structures and Custom Types

  1. Records: Named Fields and Structured Data
  2. Custom Types and Variants
  3. Generics: Writing Reusable Type-Safe Code
  4. The Result Type: Explicit Error Handling
  5. The Option Type: Handling Absence Safely
  6. Lists, Tuples, Strings, and Dictionaries
  7. Summary

Chapter 6: Functional Programming in Gleam

  1. Functions as First-Class Values
  2. Higher-Order Functions
  3. Immutability and Its Consequences
  4. Pure Functions and Side Effects
  5. Function Composition and Pipeline Design
  6. Laziness vs Eager Evaluation in Gleam
  7. Summary

Chapter 7: Modules, Organization, and Code Structure

  1. Module System Fundamentals
  2. Imports and Qualified Access
  3. Type Exports and Public Interfaces
  4. Project Structure for Growing Applications
  5. Code Organization Patterns
  6. Refactoring and Modularization Strategies
  7. Summary

Chapter 8: Error Handling and Robustness

  1. Philosophy of Explicit Errors
  2. Using Result for Recoverable Errors
  3. The Try Operator and Error Propagation
  4. Custom Error Types
  5. Panic and Unrecoverable Errors
  6. Building Fault-Tolerant Components
  7. Summary

Chapter 9: Concurrency on the BEAM: Processes, Messages, and Actors

  1. The BEAM Runtime and Why It Matters
  2. Lightweight Processes in Gleam
  3. Message Passing: Send and Receive
  4. The Actor Pattern in Practice
  5. Building Concurrent Systems
  6. Concurrency Pitfalls and Best Practices
  7. Summary

Chapter 10: OTP Concepts and Production-Concurrent Design

  1. What Is OTP and Why Gleam Uses It
  2. Supervision Trees: Letting Things Crash
  3. Gen_Server in Gleam
  4. Fault Tolerance Design
  5. Distributed Applications on BEAM
  6. Building Resilient Systems: Putting It All Together
  7. Summary

Chapter 11: Interoperability: Erlang, Elixir, and JavaScript

  1. Calling Erlang from Gleam
  2. Calling Gleam from Elixir
  3. Calling Elixir from Gleam
  4. JavaScript Compilation Target
  5. JavaScript Interoperability
  6. Polyglot BEAM Projects
  7. Platform-Specific Code and Conditional Compilation
  8. Summary

Chapter 12: The Ecosystem: Packages, Dependencies, and Tooling

  1. Hex Package Manager and gleam add
  2. Creating and Publishing Your Own Package
  3. Dependency Management Best Practices
  4. The Gleam Build Tool Deep Dive
  5. Documentation Generation and Reading Docs
  6. Community Libraries and Ecosystem Survey
  7. Summary

Chapter 13: Testing, Debugging, and Quality Assurance

  1. The Gleam Test Framework
  2. Writing Effective Tests
  3. Property-Based Testing
  4. Test Structure and Helpers
  5. Debugging Techniques
  6. Static Analysis and Linting
  7. Continuous Integration for Gleam Projects
  8. Summary

Chapter 14: Building Real Applications: Web Services, APIs, and Data

  1. Web Frameworks in Gleam
  2. Building a RESTful JSON API
  3. Working with JSON
  4. Database Access
  5. Networking and HTTP Clients
  6. Complete Application Walkthrough Summary
  7. Summary

Chapter 15: Performance, Deployment, and Production Operations

  1. Performance Characteristics of Gleam
  2. Memory Behavior and Optimization
  3. Profiling and Benchmarking
  4. Deployment Options
  5. Observability in Production
  6. Security Considerations
  7. Summary

Chapter 16: Advanced Patterns and Idiomatic Gleam

  1. Common Design Patterns in Gleam
  2. Domain Modeling with Custom Types
  3. Effect Systems and Managed Side Effects
  4. Macro Programming and Why Gleam Avoids Them
  5. Migration Strategies
  6. Building Maintainable Long-Term Gleam Systems
  7. Summary

Conclusion: The Future of Gleam and Your Journey Ahead

  1. Where Gleam Is Headed
  2. The BEAM Ecosystem’s Future Role
  3. Your Path Forward as a Gleam Developer
  4. Final Thoughts on Simplicity, Reliability, and Joy in Programming

References

  1. Official Gleam Resources
  2. Language Design and History
  3. BEAM Runtime and OTP
  4. Standard Library
  5. Web Development and Frameworks
  6. Databases
  7. Testing and Tooling
  8. Deployment and Operations
  9. Community and Learning Resources
  10. Comparative and Analytical Sources

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub