More reliable
A small, regular grammar leaves the model far less surface area to get wrong.
A compact language designed for models to generate. It compiles to the readable JavaScript and TypeScript your team already runs, reviews and trusts.
import { Hono } from "hono";
import { openDb, defineTable, dbAll, dbAdd } from "./server.js";
const env = readEnv(["PORT", "DATABASE_URL"]);
const db = openDb(env.DATABASE_URL);
const users = defineTable(db, "users", {
columns: [{ name: "name", type: "str" },
{ name: "email", type: "str", unique: true }]
});
const app = new Hono();
app.get("/users", async (c) => reply(c, ok(dbAll(users))));
app.post("/users", async (c) => {
const body = await readBody(c, { name: "str", email: "str" });
if (!body.ok) return c.json({ error: "invalid body" }, 400);
return reply(c, ok(dbAdd(users, body.value)));
});
serve(app, env.PORT);
(env PORT DATABASE_URL)
(server api :port PORT
(db users {name: str, email: str unique})
(route GET "/users" (ok (db.all users)))
(route POST "/users" {name email}
(ok (db.add users {name email}))))
Measured, not marketed
We asked leading models to solve the same coding tasks in JavaScript and KernScript, then ran every result. No vibes. No cherry-picking. Just programs that work, or do not.
Real runs across six analyses. Every program was checked by actually running it. The gap is widest on full backends and agents, where a smaller language gives models far less surface area to get wrong.
What the model writes
Relations, validation, auth, transactions and tools are first-class forms. KernScript compiles them to idiomatic JavaScript your team can inspect and ship.
(env PORT DATABASE_URL API_KEY)
(server shop :port PORT
(db categories {name: str unique})
(db products {name: str nonempty, price: (num :min 0),
stock: num, category: ref categories})
(db orders {product: ref products, qty: (num :min 1)})
(auth :apikey)
(route GET "/products" :public
(ok (db.all products :order price)))
(route POST "/orders" {product qty}
(let p (db.get products product))
(if (not p) (err 404 "no product")
(if (< p.stock qty) (err 400 "insufficient stock")
(ok (tx
(db.set products product {stock: (- p.stock qty)})
(db.add orders {product qty})))))))
(env FEED_URL)
(let people (fetch FEED_URL))
(let adults (filter people (fn [p] (>= p.age 18))))
(let byCity (groupBy adults (fn [p] p.city)))
(let rows (map (entries byCity) (fn [e]
(let ps (at e 1))
(let total (reduce ps (fn [s p] (+ s p.age)) 0))
{city: (at e 0), count: (len ps),
avg: (toFixed (/ total (len ps)) 1)})))
(let ranked (sort rows (fn [r] (- 0 r.count))))
(for r ranked
(print "{r.city}: {r.count} people, avg {r.avg}"))
(tool add (desc "add a and b")
(in {a: num, b: num}) (out {sum: num})
{sum: (+ a b)})
(tool lookup (desc "count feed records")
(in {q: str}) (out {n: num}) (retry 2) (timeout 5000)
(let d (fetch FEED_URL {q})) {n: (len d)})
(agent helper (model "claude-sonnet-4-6")
(system "You are a helpful assistant.")
(tools [add lookup])
(memory chat :max 30 :persist "agent-mem.db")
(permission [:net]))
(let answer (ask helper "Find and summarize the records"))
(print answer.text)
(env PORT DATABASE_URL JWT_SECRET)
(server blog :port PORT
(db authors {name: str, email: (str :email) unique})
(db posts {title: (str :len 1 100), body: str,
author: ref authors, published: bool})
(db comments {post: ref posts, text: str})
(auth :jwt)
(route GET "/posts" :public (ok (db.all posts)))
(route POST "/posts" {title body author published}
(ok (db.add posts {title body author published})))
(route POST "/posts/:id/comments" {text}
(ok (db.add comments {post: id, text})))
(route GET "/stats" :public
(ok {posts: (db.count posts),
comments: (db.count comments)})))
Smaller surface. Bigger outcomes.
Models are astonishing pattern machines. KernScript gives them fewer patterns to choose from and makes every one count.
A small, regular grammar leaves the model far less surface area to get wrong.
One-line compiler diagnostics guide the next correction instead of another full rewrite.
Uniform forms reduce the choices the model must make before it can solve the actual problem.
Readable JavaScript or strict TypeScript. Your runtime, your review process, your stack.
Everything has one shape: (form args). Almost nothing to memorize, very little to hallucinate.
The compiler awaits what suspends. You never write await, then or Promise.all.
Inference, records, unions and diagnostics designed for fast model repair.
Routes, validation, relations, transactions and auth without the glue.
Tools, retries, timeouts and persistent memory across leading providers.
Ready when your model is
The language reference fits in a few thousand tokens. Put it in context and your model can write KernScript immediately.
$ git clone https://github.com/kernscript/kernscript
$ cd kernscript && npm install
$ npx ks run examples/hello.ks
✓ Hello, world!