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.
Working on the compiler itself:
make # build ./slangc against this working tree
make test # compile & run the example programs
make docs # rebuild the documentation siteStarting 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 immediately execute the result |
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.