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.

#ChapterWhat you'll learn
01Getting StartedFire up the REPL, send your first message, understand how expressions work
02Basic TypesEvery value is an object: Integer, Float, String, Boolean, Nil, Symbol, Character
03Variables:= assignment, temporary variables, lexical scope
04MessagesThe core concept. Unary, binary, and keyword messages; cascade; precedence rules
05Arithmetic & ComparisonNumeric 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.

#ChapterWhat you'll learn
06StringsUTF-8 text, ++ concatenation, {interpolation}, grapheme clusters, common methods
07BlocksClosures as first-class values; value:, valueWithArguments:; variable capture
08Control FlowifTrue:ifFalse:, whileTrue:, timesRepeat:, to:do:, match:
09CollectionsArray, Dictionary, Bag, Set; collect:, select:, inject:into:

Part 3 — Object-Oriented Beamtalk

Classes, concurrency, and error handling — the three pillars of production Beamtalk code.

#ChapterWhat you'll learn
10Value ClassesImmutable data objects with Value subclass:; slots, constructors, equality
11ActorsConcurrent objects with Actor subclass:; spawn, send:, mutable state
12Error Handlingon:do: exceptions, the Result type, doesNotUnderstand
13Testing with BUnitTestCase 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.

#ChapterWhat you'll learn
14Pattern MatchingDestructuring arrays, maps, and tuples; binary patterns with match:
15Type AnnotationsThe :: syntax, gradual typing, method signatures
16BEAM InteropCalling Erlang from Beamtalk, atoms, tuples, Erlang module function:
17OTP SupervisorsSupervisor 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.

#ChapterWhat you'll learn
18File I/OReading, writing, directory operations, lazy file streams
19Regular ExpressionsPattern matching, find/replace, splitting, compiled regex
20JSONParsing, generation, nested structures, round-tripping
21DateTime & TimeConstruction, formatting, arithmetic, comparisons, high-resolution timestamps

Part 6 — The Environment

The workspace globals you'll use in every REPL session.

#ChapterWhat you'll learn
22Workspace & GlobalsTranscript logging, Workspace introspection, Beamtalk reflection, custom bindings

Part 7 — Advanced Topics

Lazy evaluation, metaprogramming, and real-world networking.

#ChapterWhat you'll learn
23StreamsLazy evaluation, infinite sequences, stream pipelines, collection interop
24Reflection & MetaprogrammingrespondsTo:, fieldAt:, perform:, metaclasses, class hierarchy
25HTTP ClientGET/POST/PUT/DELETE, response parsing, JSON APIs, configurable client actor
27Generics & ProtocolsParametric types Result(T, E), structural protocols, union types, narrowing

Appendix

#ChapterWhat you'll learn
26GlossaryKey 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