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.
Próximamente
Si deseas recibir actualizaciones para este libro, puedes proporcionar tu nombre y email para ser suscrito al boletín de noticias:
Descripción
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.
Contenido
Introducción
-
Introduction preparado
An introduction to the book’s approach, Glim and the learning journey.
Capítulos
-
Hello, Glim… Gleam? por hacer
Install Erlang + Gleam, `gleam new`, `gleam run`, the shape of a program.
-
A room, a prompt, a command por hacer
Print a description, read a line from the keyboard, a loop, `case` on the command.
-
Rooms on a map por hacer
2–3 rooms as data (a custom type), north/south, tracking "where am I".
-
Loot, and a way to win por hacer
Items in a list, `take`/`inventory`, a win condition; a complete playable adventure.
-
Everything is a value por hacer
Everything is an expression, immutability, the basic types.
-
Functions, labels and the pipe por hacer
Arguments, labels, anonymous functions, `|>`, last expression is the return.
-
The compiler is on your side por hacer
Inference, the compiler as an ally, reading type errors.
-
Types you design yourself por hacer
The thing you used for rooms, properly; variants, constructors, records.
-
Every case covered por hacer
`case`, guards, exhaustiveness, destructuring.
-
There is no "for" loop por hacer
There is no `for` loop; the `list` module, folds, maps.
-
No null, no exceptions por hacer
No exceptions, no null; `use` for the happy path.
-
Organising code, adding packages por hacer
Organising code, `import`, a stdlib tour, adding a Hex dependency, `gleam.toml`.
-
The world, properly modelled por hacer
Rooms, exits, items and the player as well-made types; a world file.
-
From words to commands por hacer
From "take the rusty key" to a typed command; synonyms, error messages.
-
State that flows through por hacer
State as a value that flows; separating pure logic from I/O.
-
Writing the game to disk por hacer
Files, encoding/decoding JSON, `dynamic`/`decode`.
-
Tests that catch you por hacer
`gleeunit`, testing the pure logic, TDD of a feature.
-
Little processes, passing notes por hacer
What the BEAM is; `spawn`, send/receive; the actor mindset.
-
The world becomes an actor por hacer
The `actor` from `gleam_otp`; the world as an actor.
-
A world full of players por hacer
Several sessions talking to one shared world; a lobby.
-
Let it crash, then recover por hacer
"Let it crash", supervisors, restarts.
-
The same code, in a browser por hacer
Compile to JS, a minimal web front end, FFI to JS.
-
Serving the game over the web por hacer
`wisp`/`mist`, serving the adventure over HTTP/WebSocket.
-
Borrowing from Erlang and Elixir por hacer
The Erlang target, FFI, using an ecosystem library.
-
Give the engine away por hacer
Extract the engine as a library, docs, `gleam publish`, versioning.
-
Where to go from here por hacer
Bigger OTP, the community, ideas to keep hacking.