Usage / Getting started

Getting started

This page gets you from “a file” to “a runnable program”, and points you at the docs you’ll use most often.

If you already have a silk binary on your PATH, start with “Write a program”.

If you don’t, see “Build from source” for the reference compiler workflow.

Write a program#

Create hello.slk:

import { println } from "std/io";

fn main () -> int {
  println("hello from silk");
  return 0;
}

Run the normal loop:

silk check hello.slk
silk test hello.slk
silk build hello.slk -o build/hello
./build/hello

If you prefer a step-by-step walkthrough, start here:

Packages (silk.toml)#

For larger projects, describe the module set in silk.toml and use --package:

silk check --package .
silk test  --package .
silk build --package .
silk package inspect --package .
silk package lint --package .

Use inspect to confirm the package name, version, definitions, dependencies, and declared artifacts. Use lint before installation or publication to catch missing definition files, bad artifact paths, or incomplete [dist] coverage.

Reference:

Build from source (reference compiler)#

The reference Silk compiler/toolchain is built with Zig.

From the Silk compiler repository root:

make build

This builds missing hosted dependencies on supported native hosts and stages a repo-local toolchain. Among its outputs are:

  • build/bin/silk (the CLI)
  • build/bin/silk-lsp (the language server)
  • build/lib/libsilk.a (the C ABI library)
  • build/lib/silk/std/libsilk_std.a (the prebuilt stdlib archive on supported native hosts)
  • build/share/silk/std/ and build/share/man/ (stdlib sources and manpages)

For a compiler-only Zig build or a custom staging prefix, use:

zig build
zig build install --prefix build

To fetch or rebuild only the pinned hosted dependency archives:

make deps

Reference: Built-in dependencies

Troubleshooting#

  • If a command fails, look up the error code in: Diagnostics
  • If you hit backend/toolchain limits, start with: Limits

Where to go next#

Source repository · Edit this page · View Markdown