Conventional code can look correct while hiding its real behaviour inside side effects, implicit error handling, stringly typed state, and broad orchestration functions. Varyonic programming is a response to that failure mode. Programs written this way have semantics that can be directly inspected, tested, and stressed by mutation.
This matters even more for LLM-generated code, which tends to pass conventional tests while hiding mutation-blind behaviour behind mixed concerns.
The behaviour of a program should be expressed in returned data, not hidden in logs or side effects.
Not Varyonic:
import process
def check_bad(pages: List[Str]) {
print("broken links found")
process.exit(1)
}
Varyonic:
data BrokenLink {
source: Str
target: Str
}
data CheckReport {
files_checked: Int
broken_links: List[BrokenLink]
error_count: Int
}
Tests assert on structured results:
observe report.error_count == 1
If behaviour cannot be observed through returned values, mutation testing cannot measure it.
The structure of the domain should be represented explicitly with data and enum.
Not Varyonic:
def deploy_bad(mode: Str) {
if mode == "prod" {
print("deploying to prod")
}
}
Varyonic:
enum DeployTarget {
Local
Preview
Production
}
data DocPage {
slug: Str
title: Str
category: Str
order: Int
}
Types encode meaning and reduce ambiguity.
Public API routes should be declared once, in the service endpoint that owns the method, path, request shape, response shape, auth policy, cache policy, and capability requirements.
Not Varyonic:
def api_route_contract(index: Int) -> ApiRouteContract {
if index == 0 {
return route_contract("get_issues", "GET", "/api/v1/issues", "ListIssuesQuery", "IssueListResponse", "none", "public cache")
}
return route_contract("", "", "", "", "", "", "")
}
Varyonic:
service IssueTrackerService at "https://issue-tracker.local" {
endpoint get_issues(status: Str, limit: Int) -> Str
via GET "/api/v1/issues"
auth none
cache public(max_age=60, s_maxage=300)
capability issues.private.read
}
Tools should inspect vary routes --json or vary routes --openapi output
instead of parsing prose or maintaining positional indexes.
Important program behaviour should live in pure functions.
Pure logic includes classification, validation, transformation, planning, and report generation.
enum ChangeKind {
Css
Content
Template
StaticAsset
Unknown
}
def classify_change(path: Str) -> ChangeKind {
if path.endswith(".css") {
return ChangeKind.Css
}
if path.endswith(".html") {
return ChangeKind.Template
}
if path.endswith(".md") {
return ChangeKind.Content
}
return ChangeKind.Unknown
}
Put reasoning in pure functions. Effects should execute decisions, not contain them.
Programs should be structured as:
Inputs -> Pure planning -> Execution -> Structured report
data BuildStep {
source: Str
output: Str
}
data BuildPlan {
steps: List[BuildStep]
}
data BuildReport {
files_built: Int
errors: Int
}
def plan_build(sources: List[Str]) -> BuildPlan {
mut steps: List[BuildStep] = []
for s in sources {
steps = steps + [BuildStep(s, s + ".out")]
}
return BuildPlan(steps)
}
def run_build(plan: BuildPlan) -> BuildReport {
return BuildReport(len(plan.steps), 0)
}
The plan describes what should happen. Execution performs the side effects. Tests verify plan semantics separately from execution behaviour.