slang
A statically typed language built primarily for server-side and network programming. Compiles to C.
Concurrency that is actually concurrent
spawn submits a green task onto striped, work-stealing
run queues. Channels, select and mutex park
the task, never the OS thread, so a blocked handler costs a
queue slot rather than one of the pool's threads.
Errors you cannot quietly drop
opt[T] for absent data, result[T, E] for
bad data, fault for a bad world. guard let x = r
else let e = err_of(r) binds the error so it can be logged
rather than thrown away.
C is the runtime, not a foreign country
slang emits C and shells out to cc. Calling a C library
is extern fn plus a linker flag — no bindings
generator, no FFI marshalling layer, no second build system.
Built for agents to read
Every page here has a Markdown twin at the same URL, the whole site
is one file at /llms-full.txt, and every package and
function is indexed in /api.json.
Quick start
Install the compiler, then start a project:
git clone https://github.com/dolphlabs/slang && cd slang
sudo make install # /usr/local by default; PREFIX=~/.local works too
slangc new hello
cd hello
slangc main.sl --run # hello from hellomake install puts slangc in $(PREFIX)/bin and the runtime and standard library in $(PREFIX)/lib/slang — both are needed, because slangc splices its runtime C into every program it compiles. Remove it all with make uninstall. make dist builds a relocatable tarball with the same layout, which can be unpacked anywhere and run in place.
Platforms. CI builds and runs the full test suite on every merge to main on Linux x86_64 (GCC), Linux arm64 (GCC) and macOS on Apple Silicon (clang), and it is developed on macOS x86_64. Building needs a C compiler; net over TLS, crypto and httpc over https also need OpenSSL (macOS: brew install openssl; Debian/Ubuntu: apt install libssl-dev).
slangc finds OpenSSL itself: OPENSSL_DIR if set, then pkg-config, then the standard Homebrew and MacPorts locations, then brew --prefix, then the system headers. If none of those finds it and compilation fails, slangc says so and suggests the fix, rather than leaving only the compiler's "openssl/… file not found".
Working on the compiler itself:
make # build ./slangc against this working tree
make test # compile & run the example programs
make docs # rebuild the documentation siteTests live in *_test.sl files and run with slangc test — covered in the Testing section.
Starting a project#
slangc new myapp # creates myapp/ with slang.project, main.sl, .gitignore
slangc new . # same, in the directory you are already inslangc new writes slang.project but not slang.lock. The lock is derived: slangc get generates it from the pkg lines in slang.project, and a lock file for a project with no dependencies records nothing. Cargo and Go draw the same line — cargo new writes Cargo.toml and not Cargo.lock.
Scaffolding lives in slangc rather than a companion tool because the compiler already owns both formats: it parses slang.project and writes slang.lock. A separate tool would have to reimplement a grammar it does not control.
Compile a slang program:
./slangc examples/hello/main.sl # produces ./main
./main # run itUseful flags:
| Flag | Effect |
|---|---|
-o <name> | Choose the output binary name |
--emit-c | Only write the generated C file (no compilation) |
--keep-c | Keep the generated C file after compiling |
--run | Compile, then run it; exit with the program's own status |
get | Fetch slang.project pins and write slang.lock |
Want to see everything at once instead of one feature at a time? See demo/ — a full server (dice game, guestbook wall, live dashboard) exercising every tier: http/link, net.tls_*, json, spawn/chan[T], proc graceful shutdown, local package imports, and C interop, with a real HTML/CSS/JS frontend. cd demo && ./run.sh.