What Is a Data Runtime?
A data runtime runs data directly, the way a JavaScript runtime runs JavaScript. Its documents carry their own logic, so instead of a program loading some inert data and deciding what to do with it, the document has fields, types, and functions together, and the runtime runs them, sandboxed, the same on every platform.
Stof is a data runtime. The short version: JSON that runs.
What actually runs
Here's a JSON document:
{ "values": { "a": 42, "b": 24 } }
Any JSON is already valid Stof. Add a function next to the data and it's still the same document. Press Run:
{
"values": { "a": 42, "b": 24 },
fn sum() -> int {
self.values.a + self.values.b
}
}sum() isn't a separate script that knows how to read this document. It's part of it. Your app calls it the same way it reads a field, doc.call('sum'), and gets 66 back. Save the document, send it somewhere, load it in Python instead of TypeScript: sum() comes along and gives the same answer.
That's the whole definition in one example. A data runtime is the thing that makes doc.call('sum') work.
Not a format, a language, or a database
The idea is easiest to place by what it isn't.
Not a data format. JSON, YAML, and TOML describe a snapshot. The file means nothing until some program decides what to do with it. A Stof document is still data, but it can also do things.
Not a programming language. There's no compile step, no executable, and no program apart from the data. The functions exist to serve the data they sit next to. You don't write apps in Stof; you give your app documents.
Not a database. There's no query engine and no storage layer. A document is one self-contained unit, closer to an object with methods than a table with rows. Keep it wherever you keep data.
Why it needed a name
Every interchange format describes a snapshot. The moment it crosses a wire, it's inert on the other side, and whatever receives it has to already know what to do with it. That gap is where schema drift comes from, and "the API changed and nobody told the client," and the DSL every team eventually bolts onto YAML.
Those teams weren't wrong to need more than plain data. They didn't have a runtime built to hold both halves, so each built one for its own tool. A data runtime is the general version, and three properties make it one:
- Sandboxed. A document can only touch what the app running it hands it. No files, network, or environment unless the app turns them on, and every call has a time and memory limit. That's what makes logic from a model, a customer, or another service safe to run.
- Portable. The same document gives the same result natively in Rust, in WebAssembly in a browser or Node.js, and in Python.
- Live. A document can take in new fields, types, and functions while it runs. Changing behavior is sending a new document, not shipping a deploy.
The first one matters more every month. Models write more and more of the logic in our systems, and a data runtime is a safe place to run it.
FAQ
Is a data runtime a database? No. A database stores and queries many records. A data runtime document is one self-contained unit of data and logic, with no query engine or storage of its own.
How is it different from a templating engine or a DSL? A templating engine or DSL is a separate tool that reads a document and produces something. In a data runtime, the document is the thing that runs. The logic lives inside it.
Is it safe to run a document from an untrusted source? That's what the sandbox is for. A Stof document can only reach what the app running it provides, and every call has a time and memory limit. Security and the Sandbox has the whole model.
Do I have to migrate my data? No. Any JSON is already a Stof document. Using Stof is a decision to add logic where you need it, not a migration.
