Learn it once
Scripts, pages and apps run on one interpreter, so a function you write for a script works in a page unchanged.
KScript runs a terminal script, renders a live web page and draws a native window, all from one small binary on Windows, macOS and Linux.
import KScript.Terminal
input(into: name) "What's your name? "
echo "Hello, { $name->trim()->title() }!"What's your name? joan Hello, Joan!
One native program, kscript, on your PATH. Nothing else to install first.
curl -fsSL https://raw.githubusercontent.com/kylepantall/kscript/master/install.sh | shirm https://raw.githubusercontent.com/kylepantall/kscript/master/install.ps1 | iexThen run kscript ide install for your editor, or kscript make project my-app to start. More ways to install
Scripts
Real values with methods on every one, pipes, lambdas, try and catch, and functions you call like commands. This one lists everything over 1 MB in a folder, largest first.
The languageimport KScript.IO
import KScript.Terminal
$folder = $args[0] ?? @known_folder(downloads)
$big = @files($folder, pattern: '*', recursive)
|> filter(fn(f) => $f.size > 1000000)
|> sort(by: fn(f) => -$f.size)
for f in $big {
echo "{ @bold($f.name) } { ($f.size / 1000000)->round(digits: 1) } MB"
} else {
echo "Nothing over 1 MB in {$folder}."
}Data
Declare a type and the response is checked and turned into records your editor knows the fields of. Every mismatch is reported at once, with its JSON path.
Types and validationimport KScript.Net
type Repo {
name: string
stars: int from stargazers_count
owner: string from owner.login
}
$url = 'https://api.github.com/repos/kylepantall/kscript'
$repo = @api($url)->check()->convert(from: json, as: Repo)
echo "{$repo.name} by {$repo.owner} has {$repo.stars} stars"Web pages
Put a live block in a page and its buttons, inputs and forms run KScript on the server. Only that block is redrawn. The state is signed and travels with the page, so the server keeps nothing between requests.
Web pages<live id="todos">
<state name="todos" value="[]" />
<state name="draft" value="''" />
<form on-submit="add: $draft, to: $todos, set: $draft, to: ''">
<input @bind($draft) placeholder="What needs doing?">
<button>Add</button>
</form>
<ul>
<for each="t" in="$todos"><li>{$t}</li></for>
<else><li>Nothing yet.</li></else>
</ul>
<p>{ $todos->count() } to do</p>
</live>Desktop apps
A Window block opens a real window on macOS, Windows or Linux, and is redrawn after every handler. kscript compile turns it into an app that runs without kscript.
Desktop appsimport KScript.UI
Window(title: 'Counter', width: 320, height: 200) {
$count = 0
Text(size: 32) "{$count}"
Button(variant: primary, on_click: $count += 1) "Add one"
}Scripts, pages and apps run on one interpreter, so a function you write for a script works in a page unchanged.
Unknown names, bad attributes, missing imports and syntax errors are reported before the first line runs, with what to write instead.
Completion knows the type of every value, including what your own functions return. Errors show as you type.
A native program that needs no .NET and starts in milliseconds. Scripts behave the same on all three platforms.
No node_modules, no virtual environment and no bundler. Save the file and run it.
Files, HTTP, databases, sign-in, mail, queues and documents come as packages, loaded only when a script imports them.
The core language is always there. Everything else is a package a script imports, and a terminal script never loads the web server.
KScript.TerminalPrompts, menus, confirmations, file pickers and coloursKScript.IOFiles, folders and pathsKScript.NetHTTP requests and downloadsKScript.HttpRoutes, controllers and middlewareKScript.WebPages, layouts, components and live blocksKScript.DataModels, queries and migrations on SQLite, Postgres and MySQLKScript.AuthAccounts, passwords, passkeys and sessionsKScript.UINative desktop windowsKScript.DocumentPDF, Word and LaTeX papers, reports and invoicesKScript.AILanguage models, with ClaudeKScript.QueueBackground jobs with retriesKScript.MailEmail over SMTP, queued or nowKScript.MathMaths, random numbers and statisticsKScript.MarkdownMarkdown to HTMLKScript.CacheMemory and file caches, and ETagsKScript.TestTests for kscript testGenerators, a test runner, a linter, a formatter, a server and a compiler all come with kscript. Tests are KScript too.
test(name: 'greets by name') {
expect(@greeting('Joan'), equals: 'Hello, Joan!')
}kscript make project my-appkscript servekscript testkscript checkkscript fmtkscript compile --target allkscript ide installkscript docs