Learning Beamtalk
A progressive language guide with runnable examples. Each chapter includes exercises with collapsible solution hints to help you practice.
Most code examples in these chapters are tested automatically — if an example is wrong, CI catches it. A few chapters (22, 25, and 27) are documentation-only and not executable.
How to use this guide
Read linearly — each chapter builds on the last. If you have prior Smalltalk experience, chapters 1–3 will feel familiar; pay close attention to chapter 4 (Messages) and chapter 5 (Arithmetic) where Beamtalk diverges from classic Smalltalk.
Try it yourself — start the REPL and type along:
beamtalk repl
Chapters
Part 1 — The Basics
The first five chapters cover the fundamentals you need before writing any real code: types, variables, and the message-passing model that underlies everything in Beamtalk.
| # | Chapter | What you'll learn |
|---|---|---|
| 01 | Getting Started | Fire up the REPL, send your first message, understand how expressions work |
| 02 | Basic Types | Every value is an object: Integer, Float, String, Boolean, Nil, Symbol, Character |
| 03 | Variables | := assignment, temporary variables, lexical scope |
| 04 | Messages | The core concept. Unary, binary, and keyword messages; cascade; precedence rules |
| 05 | Arithmetic & Comparison | Numeric operators, division, equality (==, =:=, /=), ordering |
Part 2 — Working with Data
With the basics in hand, these chapters cover the types and structures you'll use most in everyday code.
| # | Chapter | What you'll learn |
|---|---|---|
| 06 | Strings | UTF-8 text, ++ concatenation, {interpolation}, grapheme clusters, common methods |
| 07 | Blocks | Closures as first-class values; value:, valueWithArguments:; variable capture |
| 08 | Control Flow | ifTrue:ifFalse:, whileTrue:, timesRepeat:, to:do:, match: |
| 09 | Collections | Array, Dictionary, Bag, Set; collect:, select:, inject:into: |
Part 3 — Object-Oriented Beamtalk
Classes, concurrency, and error handling — the three pillars of production Beamtalk code.
| # | Chapter | What you'll learn |
|---|---|---|
| 10 | Value Classes | Immutable data objects with Value subclass:; slots, constructors, equality |
| 11 | Actors | Concurrent objects with Actor subclass:; spawn, send:, mutable state |
| 12 | Error Handling | on:do: exceptions, the Result type, doesNotUnderstand |
| 13 | Testing with BUnit | TestCase subclass:, assert:equals:, should:raise:, setUp/tearDown |
Part 4 — Advanced Features
Pattern matching, the type system, and BEAM interoperability for when you need the full power of the platform.
| # | Chapter | What you'll learn |
|---|---|---|
| 14 | Pattern Matching | Destructuring arrays, maps, and tuples; binary patterns with match: |
| 15 | Type Annotations | The :: syntax, gradual typing, method signatures |
| 16 | BEAM Interop | Calling Erlang from Beamtalk, atoms, tuples, Erlang module function: |
| 17 | OTP Supervisors | Supervisor subclass:, restart strategies, fault-tolerant trees |
Part 5 — Practical Stdlib
The standard library APIs you'll reach for most often: file handling, text processing, and data interchange.
| # | Chapter | What you'll learn |
|---|---|---|
| 18 | File I/O | Reading, writing, directory operations, lazy file streams |
| 19 | Regular Expressions | Pattern matching, find/replace, splitting, compiled regex |
| 20 | JSON | Parsing, generation, nested structures, round-tripping |
| 21 | DateTime & Time | Construction, formatting, arithmetic, comparisons, high-resolution timestamps |
Part 6 — The Environment
The workspace globals you'll use in every REPL session.
| # | Chapter | What you'll learn |
|---|---|---|
| 22 | Workspace & Globals | Transcript logging, Workspace introspection, Beamtalk reflection, custom bindings |
Part 7 — Advanced Topics
Lazy evaluation, metaprogramming, and real-world networking.
| # | Chapter | What you'll learn |
|---|---|---|
| 23 | Streams | Lazy evaluation, infinite sequences, stream pipelines, collection interop |
| 24 | Reflection & Metaprogramming | respondsTo:, fieldAt:, perform:, metaclasses, class hierarchy |
| 25 | HTTP Client | GET/POST/PUT/DELETE, response parsing, JSON APIs, configurable client actor |
| 27 | Generics & Protocols | Parametric types Result(T, E), structural protocols, union types, narrowing |
Appendix
| # | Chapter | What you'll learn |
|---|---|---|
| 26 | Glossary | Key terms: slot, message, actor, block, non-local return, value class, cascade, DNU, BEAM, OTP |
Format conventions
Expression chapters (chapters 1–9, 15, 19–21, 23) — inline assertions:
3 + 4 // => 7
"hello" size // => 5
Class chapters (chapters 10–14, 16, 18, 24) — BUnit assertions:
TestCase subclass: Ch10Examples
testPointConstruction =>
p := Point x: 3 y: 4
self assert: p x equals: 3
Wildcard _ matches any value (used for setup expressions):
counter := Counter spawn // => _
Error assertions:
42 unknownMessage // => ERROR:does_not_understand
See also
docs/beamtalk-language-features.md— full language referencedocs/beamtalk-syntax-rationale.md— why the syntax is the way it isdocs/beamtalk-tooling.md— CLI, REPL, VS Code, MCP, and testing