← All stories
● Covered by 1 source · 1 reportLow impact1 neutral

Deterministic Core, Non-Deterministic Shell: Expanding on Functional Core/Imperative Shell

🔄 Updated 3d ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • Functional Core/Imperative Shell separates business logic from IO.
  • Functional Core is purely functional, isolated, and testable.
  • Deterministic behavior, not just functional purity, enables testability.
  • State machines can provide deterministic core benefits.

Revisiting Functional Core/Imperative Shell

The concept of "Functional Core, Imperative Shell," coined by Gary Bernhardt fourteen years ago, divides application code into two main parts. The Functional Core handles business logic without IO or destructive state updates, while the Imperative Shell manages state, external dependencies, and interactions with the outside world.

Characteristics of Core and Shell

The Functional Core is designed to be purely functional, meaning the same inputs consistently produce the same outputs. This isolation makes it highly amenable to testing, as there are no external dependencies to mock or stub. The Imperative Shell, conversely, has less complex logic but is responsible for coordinating with external systems like databases or APIs.

Determinism Beyond Pure Functions

The article argues that the key property making pure functions testable is determinism, not necessarily pure functional programming itself. Determinism ensures that given a specific sequence of inputs, the system's behavior is repeatable and predictable. This allows for reliable testing of the core's logic.

State Machines as Deterministic Cores

The author demonstrates that state machines can also provide deterministic behavior, similar to pure functions. An example of an `AddMachine` shows that even with imperative state updates, a consistent sequence of calls to its `transition` function will always result in the same final state. This suggests that state machines can serve as deterministic cores, offering the same testability benefits where pure functional approaches might be impractical due to language or performance constraints.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

The daily brief

One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.

One email a day. Unsubscribe in one click, any time.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~26 min · 21 stories · Sep 23

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

This article re-examines Gary Bernhardt's "Functional Core, Imperative Shell" architecture, proposing that the core can be deterministic even if not purely functional. It suggests that state machines can achieve the same testability benefits as pure functions for the core component. This perspective offers an alternative for structuring applications where pure functional programming might not be feasible.