Finite-state machine
A finite-state machine is a computational model with a finite set of states and defined transitions between them, typically determined by inputs or events.
Natural Language Processing in Action, Second Edition
A finite state machine is a computational model that transitions among a finite set of states in response to input symbols.
- How it is used
- Deploys finite-state machines for regular-expression matching, controlled chatbot responses, and sentence-boundary detection.
- How deep it goes
- Explains transitions, deterministic matching, halting, and practical regex behavior while deferring detailed FSM theory and mathematics.
- Examples
- Uses greeting chatbots, regular-expression matches, character-by-character scanning, and sentence-segmentation patterns as concrete demonstrations.
- What you can do after
- Build it from scratch with regular expressions to recognize greetings, trigger responses, extract information, or segment sentences.
Read how Natural Language Processing in Action, Second Edition explains finite-state machine →
React in Depth
A state machine is a computational model that represents behavior as discrete states and transitions triggered by events or conditions.
- How it is used
- Manages React application flow and business data by restricting available transitions while keeping shared data in machine context.
- How deep it goes
- Develops a state diagram into an XState machine, actions, React hooks, and persistence; does not examine XState internals.
- Examples
- Uses a signup flow and a list-and-detail application with distinct view events, context updates, and persisted state.
- What you can do after
- Apply it via XState and @xstate/react to define permitted events, update context, expose data to components, and restore machine state.
Microservices Patterns, Second Edition
A state machine is a computational model consisting of states and defined transitions between them in response to events or conditions.
- How it is used
- Uses state machines to make orchestration-based saga execution explicit and facilitate design, implementation, and testing.
- How deep it goes
- Explains states, actions, transitions, persistent instance state, and HTTP-driven execution with retries.
- Examples
- Illustrates a Create Order Saga with order creation, credit reservation, rejection, and distinct final outcomes.
- What you can do after
- Evaluate how to execute saga orchestration with persistent state, retries, and duplicate handling.
Read how Microservices Patterns, Second Edition explains finite-state machine →
Akka in Action, Second Edition
A state machine is a computational model whose behavior depends on a finite or otherwise defined current state and its transitions.
- How it is used
- Uses state-specific actor behaviors to enforce lifecycle rules such as disabling wallet changes or closing conversations.
- How deep it goes
- Defines FSMs and works through two wallet behaviors, their commands, state transitions, and observable output without formal detail.
- Examples
- Demonstrates an activated/deactivated wallet and a conversation that changes from started to closed.
- What you can do after
- Build it from scratch with actor behaviors that retain state, ignore invalid commands, and switch handling for later messages.
Read how Akka in Action, Second Edition explains finite-state machine →
Healthcare IT
A state machine is a computational model that represents behavior as transitions among a defined set of states in response to events or conditions.
- How it is used
- Manages EHR clinical workflows as machine-readable, event-driven processes rather than passive records.
- How deep it goes
- Explains lifecycle states, transition enforcement, timestamps, audit trails, and interacting state machines, stopping short of implementation code.
- Examples
- Uses a CBC order progressing from Null through Draft, Active, Transmitted, In Process, and Completed.
- What you can do after
- Build workflow logic that validates transitions, records actors and timestamps, prevents skipped steps, and triggers downstream clinical actions.
Idiomatic Rust
A state machine is a computational model whose behavior changes according to its current state and explicitly defined transitions.
- How it is used
- Models stateful user sessions so permitted actions depend on the session's current state.
- How deep it goes
- Works through marker types, a generic session, and transition methods; leaves real session-ID lookup and validation unimplemented.
- Examples
- Uses an anonymous-to-authenticated user session with property updates and logout, plus a coroutine that yields before completing.
- What you can do after
- Build it from scratch using Rust marker types and state-specific methods to restrict session transitions at compile time.
Crack Any Codebase with AI
A state machine is a computational model in which an entity occupies one of a defined set of states and changes state through specified transitions.
- How it is used
- Uses schema enums to reveal business lifecycles and direct investigation toward the application rules governing record transitions.
- How deep it goes
- Defines explicit states and transition significance, but stops short of enumerating every valid transition or implementing enforcement logic.
- Examples
- Uses Cal.com booking statuses, pending-to-accepted movement, cancellation tracking, and a minimal SQL booking schema.
- What you can do after
- Evaluate booking workflows by identifying allowed states and locating the application rules that must enforce their transitions.
Read how Crack Any Codebase with AI explains finite-state machine →
C++ Concurrency in Action, Second Edition
A finite state machine is a computational model with a finite set of states and transitions triggered by inputs or events.
- How it is used
- Uses state machines to reason about message-passing threads that update state and send messages.
- How deep it goes
- Explains state-dependent message handling through ATM code, without formalizing the complete machine.
- Examples
- Uses ATM interactions, including card insertion, PIN entry, correction, and cancellation.
- What you can do after
- Apply it by modeling a thread’s behavior as state-dependent message handling with possible outgoing messages.
Read how C++ Concurrency in Action, Second Edition explains finite-state machine →
Secrets of the JavaScript Ninja, Second Edition
A model of a system as a set of states and transitions between those states.
- How it is used
- Explains generator execution as movement between states triggered by iterator requests.
- How deep it goes
- Defines four generator states and their transitions, then turns toward execution contexts.
- Examples
- Uses a generator that yields “Hattori skulk” and returns “Yoshi skulk.”
- What you can do after
- Understand how iterator requests advance a generator through its lifecycle.
Read how Secrets of the JavaScript Ninja, Second Edition explains finite-state machine →
Build and Orchestrator in Go (From Scratch)
A state machine is a computational model consisting of defined states and transitions between those states in response to events or conditions.
- How it is used
- Uses explicit state transitions to control task processing inside an orchestration worker.
- How deep it goes
- Defines states, models valid transitions, and implements lookup helpers, while stopping short of production-scale orchestration complexity.
- Examples
- Uses Pending, Scheduled, Running, Completed, and Failed states with scheduling, starting, and stopping events.
- What you can do after
- Build a small task state machine and validate transitions through a map and helper functions.
Read how Build and Orchestrator in Go (From Scratch) explains finite-state machine →
High Performance Unity Game Development
A computational model that represents behavior as a finite set of states and transitions between them.
- How it is used
- Tracks the active menu and coordinates menu and board visibility during transitions.
- How deep it goes
- Implements enum-based state updates and conditional visual changes, while noting alternative implementations without comparing them.
- Examples
- Uses main-menu, in-game, game-over, and pause-menu states, with board visibility varying by transition.
- What you can do after
- Apply it via SetMenuState() to switch menu states and update the corresponding visuals.
Read how High Performance Unity Game Development explains finite-state machine →
Fabulous Adventures in Data Structures and Algorithms
A finite state automaton, or finite state machine, is a computational model with finitely many states and transitions governed by input-dependent rules.
- How it is used
- Models input-driven behavior and connects tries to memory-efficient word-list storage.
- How deep it goes
- Defines states, inputs, transitions, and accepted languages, then frames minimization without detailing a specific algorithm.
- Examples
- Uses a vending machine and a trie recognizing a word list, with word completion and word-game moves as applications.
- What you can do after
- Understand how trie nodes encode states and why merging equivalent states can reduce storage without changing accepted words.
Read how Fabulous Adventures in Data Structures and Algorithms explains finite-state machine →
Functional Programming in Scala, Second Edition
A state machine is a computational model whose behavior is determined by a current state and input-driven transitions.
- How it is used
- Models input-driven behavior while replacing mutable data and side effects with explicit state transitions.
- How deep it goes
- Defines states and transition rules, then applies them through State combinators in a candy-dispenser exercise.
- Examples
- Uses a locked or unlocked candy dispenser with coin and turn inputs, tracked candies, and accumulated coins.
- What you can do after
- Builds a finite-state simulation that processes inputs and returns final machine values through State.
Read how Functional Programming in Scala, Second Edition explains finite-state machine →
Also covered in
- Type-Driven Development with Idris
- C# Concurrency: Asynchronous and multithreaded programming
- Amazon Web Services in Action, Third Edition: An in-depth guide to AWS
- API Design Patterns
- Rust in Action: Systems programming concepts and techniques
- Event Processing in Action
- Retrieval Augmented Generation, The Foundational IdeasIn early access (MEAP)
- Think Distributed Systems
- Regular Expression Puzzles and AI Coding Assistants
- Agent Design PatternsIn early access (MEAP)
What to know first
- business logicBusiness logic is the domain-specific rules, computations, and decisions that determine how a software system processes operations and behaves.
- type systemA type system is a set of rules that classifies program values and expressions and constrains their valid uses and operations.
- queueA queue is an ordered collection that holds items for retrieval or processing, commonly in first-in, first-out order.
- async/awaitAsync/await is language syntax for defining asynchronous computations that can suspend at awaited operations and resume when those operations produce results.
Related concepts
- data typepart of · A data type classifies values by their permitted forms or representations and the operations or interpretations applicable to them.
- state transitionhas part · A state transition is a change from one defined state of a system, object, or process to another according to an action, event, condition, or rule.
- coroutineimplements · A coroutine is a computation that can suspend and later resume execution while retaining its state, enabling cooperative transfer of control.
- agent orchestrationincludes · Agent orchestration is the coordination of agents, their tasks, tools, and interactions to accomplish a larger objective or workflow.
Questions about finite-state machine
What is finite-state machine?
A finite-state machine is a computational model with a finite set of states and defined transitions between them, typically determined by inputs or events.
Which Manning books explain finite-state machine?
Natural Language Processing in Action, Second Edition, React in Depth, Microservices Patterns, Second Edition, Akka in Action, Second Edition, Healthcare IT, Idiomatic Rust, Crack Any Codebase with AI, C++ Concurrency in Action, Second Edition and 5 more.
What should I know before learning finite-state machine?
Manning books that teach finite-state machine usually introduce business logic, type system, queue and async/await first.
What kinds of finite-state machine are there?
Kinds of finite-state machine include agent orchestration and deterministic state machine.
What is finite-state machine part of?
Finite-state machine is part of data type. A data type classifies values by their permitted forms or representations and the operations or interpretations applicable to them.
What are the parts of finite-state machine?
Finite-state machine includes state transition.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.












