book cover

EN In process pages

Gleam

Gleam

Let the development shine

Learn Gleam by building a text adventure: explore rooms, collect items and bring a world to life through your commands. A practical journey from your first steps to types, testing and concurrency, with Glim as your guide.

Book in preparation. Subscribe for news about the English edition.

Coming soon

If you want to get updates for this book, provide your name and email:

Description

Your first adventure starts with a line of code

This book takes a project-based approach to learning Gleam. Start with a room and a few commands, then revisit the ideas behind your code and grow your adventure step by step.

Learn by building

The planned journey covers values and functions, custom types, pattern matching, lists and recursion, Result and Option, modules and packages. No previous programming experience is required: start with the project or read the fundamentals first.

From one room to a shared world

The planned contents include a command parser, saved games and automated tests. They then introduce processes, actors and supervision on the BEAM, before exploring JavaScript, a web server and interoperability with Erlang and Elixir.

With Glim by your side

A little will-o’-the-wisp accompanies you with hints and pointers to the chapters that explain each concept.

This edition is in preparation. The contents are provisional and may change during writing. Sales and preorders are not open yet. Subscribe to hear about its progress.

Content

27 sections

Introduction

  • Introduction prepared

    An introduction to the book’s approach, Glim and the learning journey.

Chapters

  • Hello, Glim… Gleam? to do

    Install Erlang + Gleam, `gleam new`, `gleam run`, the shape of a program.

  • A room, a prompt, a command to do

    Print a description, read a line from the keyboard, a loop, `case` on the command.

  • Rooms on a map to do

    2–3 rooms as data (a custom type), north/south, tracking "where am I".

  • Loot, and a way to win to do

    Items in a list, `take`/`inventory`, a win condition; a complete playable adventure.

  • Everything is a value to do

    Everything is an expression, immutability, the basic types.

  • Functions, labels and the pipe to do

    Arguments, labels, anonymous functions, `|>`, last expression is the return.

  • The compiler is on your side to do

    Inference, the compiler as an ally, reading type errors.

  • Types you design yourself to do

    The thing you used for rooms, properly; variants, constructors, records.

  • Every case covered to do

    `case`, guards, exhaustiveness, destructuring.

  • There is no "for" loop to do

    There is no `for` loop; the `list` module, folds, maps.

  • No null, no exceptions to do

    No exceptions, no null; `use` for the happy path.

  • Organising code, adding packages to do

    Organising code, `import`, a stdlib tour, adding a Hex dependency, `gleam.toml`.

  • The world, properly modelled to do

    Rooms, exits, items and the player as well-made types; a world file.

  • From words to commands to do

    From "take the rusty key" to a typed command; synonyms, error messages.

  • State that flows through to do

    State as a value that flows; separating pure logic from I/O.

  • Writing the game to disk to do

    Files, encoding/decoding JSON, `dynamic`/`decode`.

  • Tests that catch you to do

    `gleeunit`, testing the pure logic, TDD of a feature.

  • Little processes, passing notes to do

    What the BEAM is; `spawn`, send/receive; the actor mindset.

  • The world becomes an actor to do

    The `actor` from `gleam_otp`; the world as an actor.

  • A world full of players to do

    Several sessions talking to one shared world; a lobby.

  • Let it crash, then recover to do

    "Let it crash", supervisors, restarts.

  • The same code, in a browser to do

    Compile to JS, a minimal web front end, FFI to JS.

  • Serving the game over the web to do

    `wisp`/`mist`, serving the adventure over HTTP/WebSocket.

  • Borrowing from Erlang and Elixir to do

    The Erlang target, FFI, using an ecosystem library.

  • Give the engine away to do

    Extract the engine as a library, docs, `gleam publish`, versioning.

  • Where to go from here to do

    Bigger OTP, the community, ideas to keep hacking.

Authors

MÁ

Manuel Ángel Rubio Jiménez

Polyglot Developer, Writer, Manager and Trainer

He started programming at the age of 12 with languages such as GW-BASIC, QBasic, MODULA-2, Pascal and C. When he started working he already mastered Java, JavaScript, PHP, Perl, Ruby, Python among others and later he would start with Rust , Golang, Erlang, Elixir and Gleam. But what attracts him most is being able to teach programming in those languages to others. He began his training as a teacher attending a course in London and later as a mentor for Erlang, Elixir, OTP, Ecto and other technologies within Erlang Solutions Ltd. Writing books is for Manuel another way not only to teach but also to learn, as and as Feynman said.

Information

Number of pages In process
Edition (1st) First edition
Language en
Author Manuel Ángel Rubio Jiménez