Documentation

Get started with Bock

Install Bock, write your first function, and build it for your stack.

01

Install

Bock ships as a single binary for macOS, Linux, and Windows.

Cargo (any platform with Rust installed):

terminal BASH
cargo install bock

Pre-built binaries: download from GitHub Releases for macOS, Linux, and Windows.

Verify the install:

terminal BASH
bock --version
02

Your first project

Scaffold a new project:

terminal BASH
bock new hello
cd hello

You'll get this layout:

hello/
hello/
├── bock.project
├── .gitignore
├── src/
│   └── main.bock
└── tests/

bock.project is the project config (TOML, similar to Cargo.toml or pyproject.toml). It includes a commented-out [ai] block. Bock uses rule-based code generation by default; AI is opt-in. src/main.bock is the entry point. tests/ is where your tests go. The .gitignore is pre-populated with sensible defaults including the .bock/ cache directory that gets created on first build.

Open src/main.bock. The starter prints "Hello, world!":

src/main.bock BOCK
fn main() {
  println("Hello, world!")
}

Make it yours.

03

Build for your target

Bock supports JavaScript, TypeScript, Python, Rust, and Go in v1. The same source compiles to any of them.

JavaScript:

terminal BASH
bock build --target js

Go:

terminal BASH
bock build --target go

The JavaScript output uses console.log and ES modules. The Go output uses fmt.Println and follows gofmt conventions. Idiomatic here means the generated code follows each language's conventions rather than mechanically translating Bock's syntax.

04

Run it

For development, run the source directly through the interpreter:

terminal BASH
bock run

This skips codegen entirely, which makes the iteration loop fast.

To run the compiled output, build first then invoke the target's runtime:

terminal BASH
bock build --target js
node build/js/main.js

The compiled JavaScript runs on Node without anything from Bock imported at runtime. The compiled output is your code. Bock isn't in the picture at runtime.

05

Where to next

The full language reference is at the documentation.

Bock is open source under the MIT License.

Back to the homepage when you're ready.

Home