bork

module
v0.0.200 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT

README

bork

Pre-alpha. The language is still changing, and programs may need updating between versions.

bork is a programming language for backend services. Its compiler checks more than types: that a value was validated before it is used, which functions do I/O, that a file or connection is still open, and that every case of a result is handled. There is no null and there are no exceptions. Programs compile to a single executable.

Bork bork bork! The name comes from the Swedish Chef. Strict recipes, cheerfully enforced.

A quick look

type User = { name: String, email: Option[String] }
type NotFound = { id: Int }

pred positive(x: Int) { x > 0 }

fn findUser(id: Int where positive): User | NotFound {
  if (id == 1) {
    User { name: "Ada", email: Option.None }
  } else {
    NotFound { id: id }
  }
}

fn describe(id: Int where positive): String {
  match (findUser(id)) {
    User { name, email: .Some(value) } => s"$name <$value>"
    User { name } => name
    NotFound { id: missing } => s"no user with id $missing"
  }
}

fn greet(id: Int) uses io {
  if (positive(id)) { println(describe(id)) } else { println("ids start at 1") }
}

fn main() {
  greet(1)
}

findUser returns one of two outcomes, and match must handle both. pred declares a check, and where positive makes every caller of describe prove it. describe is also pure: only greet says it does I/O. Break any of these rules and bork check users.bork stops you:

users.bork:15:3: match is not exhaustive: missing NotFound
users.bork:23:20: describe requires id to be positive, but that is not proven for id (check it first with if (positive(id)) { ... }, or require it: id: Int where positive)
users.bork:15:3: describe uses io (it calls println), but its signature allows no effects; declare it: uses io

Those come from three separate edits: deleting the NotFound arm, calling describe(id) in greet without the if, and adding println(id) as the first line of describe.

Install

bork compiles through Go. With Go installed:

go install github.com/GiGurra/bork/cmd/bork@latest

Or with Homebrew, which installs Go for you:

brew install gigurra/tap/bork

Prebuilt archives are on GitHub Releases. See installing bork for Go versions, upgrades and pinning a compiler version.

Quick start

bork new hello      # or --template cli, http, or lib
cd hello
bork run .
bork test .

A single file works too: bork run hello.bork, or bork script hello.bork for a script with top-level statements or fn main(). The tour continues from here.

Highlights

  • Unions and exhaustive matching: failures are values, and every case is handled.
  • Facts: check a value once, and the compiler remembers it.
  • Effects: signatures say which functions do I/O, networking, or read the clock.
  • Scopes and tasks: files, connections and concurrent tasks cannot outlive their scope.
  • Channels: typed communication between tasks, with select and timeouts.
  • Compile-time evaluation: comptime blocks run while compiling and become data.
  • Typed interpolation: sql.SQL"..." keeps inserted values out of the query text.
  • Testing: tests live next to the code, with snapshots, mocks and property tests.
  • Standard packages: files, HTTP, JSON, SQL, CLI apps, time, and more.
  • Fast rebuilds: unchanged programs start without recompiling.

Editors and playground

  • VS Code: install with bork editor install vscode, including Cursor and VSCodium.
  • Other editors: Neovim, Vim, Emacs, Helix, Zed and any LSP client, plus a debugger.
  • Browser playground: check and format code without installing anything.

Documentation

License

MIT

Directories

Path Synopsis
cmd
bork command
Command bork is the bork compiler and toolchain.
Command bork is the bork compiler and toolchain.
bork-playground command
Command bork-playground exposes compiler operations inside a Web Worker.
Command bork-playground exposes compiler operations inside a Web Worker.
internal
apidoc
Package apidoc renders checked package APIs without changing source files.
Package apidoc renders checked package APIs without changing source files.
check
Package check type-checks a parsed bork package.
Package check type-checks a parsed bork package.
childproc
Package childproc runs a program in the foreground on behalf of a bork command, the way a shell would.
Package childproc runs a program in the foreground on behalf of a bork command, the way a shell would.
describe
Package describe adapts source positions to typed compiler queries.
Package describe adapts source positions to typed compiler queries.
diag
Package diag holds source positions and compiler diagnostics.
Package diag holds source positions and compiler diagnostics.
doccomment
Package doccomment gives compiler documentation and editor hover one comment model.
Package doccomment gives compiler documentation and editor hover one comment model.
driver
Package driver runs the compiler pipeline: load sources, parse, check, generate Go, and build with the Go toolchain.
Package driver runs the compiler pipeline: load sources, parse, check, generate Go, and build with the Go toolchain.
format
Package format normalizes bork source whitespace without changing its layout.
Package format normalizes bork source whitespace without changing its layout.
gen
Package gen lowers a checked bork package to Go source.
Package gen lowers a checked bork package to Go source.
gen/cmd/genstdvalidators command
genstdvalidators derives compiler-owned artifacts from embedded standard code.
genstdvalidators derives compiler-owned artifacts from embedded standard code.
gotoolchain
Package gotoolchain applies the compiler's minimum Go version to subprocesses.
Package gotoolchain applies the compiler's minimum Go version to subprocesses.
lsp
Package lsp implements bork's stdio language server.
Package lsp implements bork's stdio language server.
manifest
Package manifest reads compiler requirements without loading program sources.
Package manifest reads compiler requirements without loading program sources.
modcache
Package modcache identifies shared Go dependency sources for editing tools.
Package modcache identifies shared Go dependency sources for editing tools.
playground
Package playground exposes the compiler's process-free operations to browsers.
Package playground exposes the compiler's process-free operations to browsers.
prelude
Package prelude holds the built-in types and functions that every bork package can use.
Package prelude holds the built-in types and functions that every bork package can use.
project
Package project scaffolds projects from the toolchain's bundled templates.
Package project scaffolds projects from the toolchain's bundled templates.
std
Package std holds bork's standard packages, imported as "bork/name" (import "bork/http").
Package std holds bork's standard packages, imported as "bork/name" (import "bork/http").
stdvalidators
Package stdvalidators executes generated, pinned standard-library intrinsics.
Package stdvalidators executes generated, pinned standard-library intrinsics.
syntax
Package syntax contains bork's lexer, syntax tree, and parser.
Package syntax contains bork's lexer, syntax tree, and parser.
testutil
Package testutil provides isolated compiler fixtures for toolchain tests.
Package testutil provides isolated compiler fixtures for toolchain tests.
toolchain
Package toolchain selects and caches immutable compiler installations.
Package toolchain selects and caches immutable compiler installations.
toolenv
Package toolenv resolves and persists the compiler's user settings.
Package toolenv resolves and persists the compiler's user settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL