๐Ÿ 

the zen of zef

the 10-line creed. pinned to the fridge.

1.   if it can be a pure function, make it a pure function
2.   data > code > side-effectful code
3.   don't conflate process and information constructs
4.   long live throw-away code
5.   make semantic abstraction layers explicit
6.   if it can be expressed as data, it should be expressed as data
7.   semantics > syntax, but syntax is your neighbour โ€” be kind
8.   reuse operators instead of inventing DSLs
9.   programs take data โ†’ transform โ†’ return data
10. the bar for core is HIGH; put it in userspace first

#6 is the big one

"if it can be expressed as data, it should be"

This is the principle that explains everything we've seen in the book:

When things are data, you can print them, log them, diff them, compare them, send them over a wire. The uniformity is the superpower.

the banana, the gorilla, and the jungle

a well-known OOP complaint

"You wanted a banana. But you got the gorilla holding the banana, and the jungle the gorilla lives in." OOP values reference their context; pulling one out drags everything with it.

Zef's contiguous-value design is the fix. Zef values don't have pointers to stuff off elsewhere. A Dict is a contiguous blob. You memcpy it to a file and it still works. You send it over a socket and it still works. No jungle. No gorilla.

the functional-core shell pattern, baked in

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ pure world effectful world โ”‚ โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ โ”‚ โ”‚ โ”‚ data | op | op | op โ”€โ”€โ”€โ–ถ | run โ”‚ โ”‚ ============ โ”€โ–ถ FX.SomeEffect(...) โ”‚ โ”‚ (collect-land) (run-land) โ”‚ โ”‚ โ”‚ โ”‚ โ–ฒ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ keep this line as clear as you can. โ”‚ โ”‚ code on the left is easy to test & reason. โ”‚ โ”‚ code on the right is where the world touches. โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Write pure functions that return FX values. Run them at the edge. The shape of a serious Zef app.

a short history of the ideas

ideacame from
types as setsrefinement-typed languages, set theory
pipe operatorshells, Elixir, F#
effects as dataHaskell's IO, Elm's Cmd
content-addressed functionsUnison
contiguous valuesFlatBuffers, Cap'n Proto, ZeroFormatter
actor modelErlang, Akka
multiple dispatchJulia, Common Lisp
graphs as dataDatomic, Neo4j, Wittgenstein's Tractatus

Zef isn't inventing from scratch. It's gluing together ideas that have proven themselves โ€” often in niche languages โ€” into a single pragmatic Python library.

the "why bother" summary

Why use Zef over the Python default stack? Four answers:

1. uniform vocabulary

One pipe, one collect, one run. Pure code, DB queries, HTTP responses, actor handlers โ€” all the same shape.

2. data everywhere

Your values, your types, your effects, your graphs โ€” all first-class, inspectable, shippable. No serialization tax.

3. fewer lines of glue

Because every subsystem speaks the same language (Zef values flowing through pipes), there's nothing to serialize/deserialize between them.

4. concurrency without bugs

Actors + signals + optimistic DBs + Tokio-backed runtime. You don't write locks. The model prevents the bugs.

the things zef still has to grow

Zef is moving fast. As of today:

If something in this book feels missing, check the notes โ€” the docs move faster than any tutorial.

closing thoughts

Zef asks you to treat your program like a pipeline of values. Data flows in, transforms, becomes effects, gets run. Pure code and effectful code live on obviously different sides of a single line.

This is an old idea from functional programming, freshly compiled into a Python library where you get to keep your day-to-day Python.

If you squint, Zef is "Elm for the backend." If you squint harder, it's "Erlang with a Python face." Either way: it's worth your time to learn the shape of a Zef program, because the shape is what changes how you think about building software.

your first zef program โ€” pick one

Now that you've seen it all, try to build one of:

Start simple. Grow it. Share it. And when you're lost, return to the cheat sheet on the next page.

One page left โ€” the cheat sheet. โ†’