I started thinking about Score partly through the lens of cost and security.
Rust is a useful reference point. Its language rules make important classes of mistakes harder to express. That seems particularly valuable when agents are writing software: a compiler-enforced constraint remains useful regardless of who produced the code.
But memory safety does not make a function pure. An ordinary Rust function can write a file, for example, without a separate effect declaration in its signature. Rust’s file-writing API illustrates that distinction.
For Melody, I wanted the language to say more about what a computation could do. What data does it observe? Can it change state? Can it contact another system? Whose authority does it use?
Those questions affect security, but they also affect placement, execution, and cost.
Score separates these concerns. The compiler distinguishes value computation, database reads, and state changes. External interactions cross declared capability boundaries. A helper cannot quietly turn a value computation into a network request.
That separation is foundational. It also turned out to be insufficient.
Purity is only the beginning
The first versions of Score were functional, but they still contained too much implementation. We could express a computation without side effects while prescribing a particular way to execute it.
One example was a nearest-match query. Depending on the data, workload, and objectives, it might be reasonable to scan the database and calculate distances, or to use a specialized search engine. If the application names the engine or encodes its access pattern, changing that decision becomes an application rewrite.
The application should describe the result it needs, including whether approximation is acceptable. The compiler should choose an implementation that preserves that contract. An exact search cannot silently become approximate because an approximate index is faster.
This was a constant challenge while designing with agents. The easiest way to make a particular example work was often to expose another mechanism: an engine choice, a physical index, a configuration knob. Each shortcut made the compiler’s immediate job easier and the application’s future evolution harder.
The distinction we kept returning to was between describing a result and prescribing how to produce it.
A simple Score query looks like this:
fn active_items() {
[
for item in Items
if item.active
order_by item.created_at desc
select { id: item.id, name: item.name }
].take(4)
}It specifies selection, ordering, projection, and a limit. It does not select a scan, an index, or a caching strategy.
Those are freedoms the compiler retains. They are also responsibilities it accepts.
Logical transformations
Even string manipulation raises the same question. A pure function can still prescribe a sequence of scans, intermediate strings, and allocations. We are moving toward expressing more text processing as logical matching and transformation.
For example, this existing pattern syntax describes removing a field’s surrounding quotes and replacing doubled quotes:
pattern QuotedBody = start "\"" body:(("\"\"" | [^"])*) "\"" end
pattern DoubleQuote = "\"\""
fn csv_field(value: text(max: 8192B)) {
case QuotedBody.capture(value) {
Some(m) => DoubleQuote.rewrite(m.captures.body, q -> "\"")
None => value
}
}The author describes what matches and how the result changes. The author does not manage a buffer or choose instructions.
Patterns are part of the language today. More comprehensive transformation planning—combining passes, avoiding intermediate allocations, and selecting accelerated implementations—is a direction for the compiler. We have not eliminated every lower-level text operation or built every optimization.
Hardware and infrastructure
This matters because the compiler knows the target.
SIMD is a straightforward example. Different processors expose different instruction sets and capabilities; even processors within one architecture can differ. Rust’s architecture-specific intrinsics make those distinctions explicit.
A Score application should not need to contain those distinctions. When a target gains a better implementation of a logical operation, applications using that operation should be able to benefit through a rebuild.
The same principle applies above the processor.
Cloud infrastructure offers many combinations of storage, compute, performance, and isolation. Their costs can be surprisingly difficult to compare. Object storage pricing alone can involve storage volume, requests, retrieval, and data transfer. S3’s pricing model is one example.
A compiler that knows the application’s operations, bounds, and objectives has information that a generic infrastructure calculator does not. Our ambition is to use that information to help choose an implementation and explain its tradeoffs.
This connects directly to SLOs as design inputs. A more lenient latency objective might make a simple implementation attractive. A tighter objective, larger workload, or different cost target might justify a specialized engine or a different topology.
The compiler still has to preserve the application’s guarantees. A cost objective is not permission to weaken durability or disclose data to another provider.
Separating compute and storage illustrates the scale of the ambition. For an existing data platform, adopting that architecture can require an enormous refactoring. In Melody, we want those changes to belong to the compiler, runtime, and target implementations, so applications can benefit without being rewritten around a new storage architecture.
The engineering does not disappear. It moves to a place where many applications can share it.
Caching and correctness
Caching is another example.
Putting a cache in front of a database can improve throughput. It can also introduce stale reads, another availability dependency, or a path that acknowledges a write before the promised durable state exists. The consequences depend on how the cache participates in the application’s contract.
Score does not give the application author a switch that says “put Redis here.” The design leaves caching to the implementation. A cache must preserve the declared behavior; if the application permits bounded staleness, that permission is part of its meaning.
That is an established design rule. A compiler that can reliably explore every useful caching arrangement is a longer-term goal.
Seeing the whole application
For this approach to work, Score needs to see more than database queries.
It includes application abstractions such as views and workflows because these are places where important behavior otherwise escapes the system’s understanding. A view observes application data. A workflow coordinates state changes and external interactions. Both affect security, performance, and failure handling.
Much of the difficulty in distributed systems lives at the boundaries between components: who can read what, when an external action happens, how a release changes behavior, and what happens when only part of an operation succeeds.
Score’s ambition is to describe the application across those boundaries. The fact that one concern traditionally belongs to databases, another to programming languages, and another to machine learning should not prevent the compiler from reasoning about their relationship.
That also means failures must remain visible at higher levels of abstraction.
Consider this excerpt from a workflow that fetches a page:
state Fetch3(crawl: u64, url: text(max: 2048B)) {
do web.fetch(Web.Request { url: url }) deadline 7s
on Returned(Fetched { page }) -> Saving(crawl, page, 3)
on Returned(NetworkFailure) -> Failed(crawl, 3, Failure.NetworkFailure)
on Returned(Rejected { reason, status }) ->
Failed(crawl, 3, Failure.Rejected { reason: reason, status: status })
on NotStarted(reason) ->
Failed(crawl, 3, Failure.NotStarted { reason: reason })
on Unknown(reason) -> Failed(crawl, 3, Failure.Uncertain)
on CancelRequested stay
}The distinction between an operation that did not start and one whose outcome is unknown matters. For a fetch, another attempt may be acceptable. For a payment, blindly retrying an uncertain result may be disastrous.
The language requires the application to account for those outcomes. Raising the abstraction level should preserve the distinctions needed to make a correct decision.
Making data flows explicit
Explicit effects also give us a place to describe data-flow boundaries.
Here is the corresponding capability declaration:
capability Web {
operation fetch(request: Request) -> Result {
deadline 7s
not_started NotStarted
unknown Unknown
bounds {
recipients { Recipient.PublicPage }
rate 100 per 1m
cost 1 Credits
data classes { DataClass.PublicData }
}
}
}The recipient and data-class names are application-defined. Credits is a declared accounting unit, not an automatic dollar estimate or a complete spending budget.
The useful property is that the interaction has an explicit contract. It has a recipient boundary, a rate, a cost bound, a deadline, and typed outcomes. Release binds that contract to an actual provider.
Restricted data has additional disclosure controls. The design accounts for data that influences an interaction through control flow as well as data copied directly into a request. A declaration alone does not grant permission: the application’s authority and runtime admission must permit the interaction too.
This gives us a foundation for inspecting and enforcing data flows. That matters when applications have residency requirements, handle sensitive information, or include agents processing adversarial input.
It does not establish everything a remote recipient might do after receiving data. It makes the boundary and the authority to cross it explicit.
Stronger guarantees, different isolation
There is a further possibility here that interests me: stronger guarantees could change the cost of isolation.
We often pay for layers of protection because we cannot sufficiently constrain the code inside them. Those protections remain necessary under many threat models. But a computation over public data, with tightly restricted capabilities and credible evidence about its behavior, may have different isolation requirements from arbitrary code handling secrets.
We want to explore whether a target can use that distinction to choose cheaper or more scalable execution.
This is directional work. Purity and memory safety alone do not prove that a workload can safely share a process or machine. Any such decision needs a stated threat model and evidence covering the generated code, runtime, dependencies, and external seams.
The broader objective is to preserve room for the system to improve.
The application author states what the system must do, what it may reveal, which failures it handles, and what tradeoffs it permits. The compiler and target take responsibility for realizing that intent.
As hardware, infrastructure, and implementation techniques change, that division should let an application evolve without repeatedly rewriting its meaning.