The Valk programming language
A fast, simple & safe programming language.
Native performance, a strict type system, and concise syntax. Build for Linux, macOS, and Windows.
curl -sSL https://valk-lang.dev/install.sh | bashuse valk.http
fn handler(req: http.Request) http.Response {
return http.Response.text("Hello world!")
}
fn main() {
let server = http.Server.new("127.0.0.1", 9000, handler)
server.start() ! panic("Failed to start server")
}
$ valk build server.valk --run
$ curl http://127.0.0.1:9000
Hello world!
The language
Simple to write, fast to run.
Native compilation
An embedded LLVM backend turns your code into a native binary, no runtime to install.
Strict types and generics
Nullable values, errors and generic code are checked when you build, not when you run.
Coroutines
Stackful coroutines start small, 4 to 32 KB, and grow when they need more stack.
C compatible
Call C libraries with extern and export functions to C; structs follow each platform’s C ABI.
Package manager
vman installs packages for your project and switches between Valk versions.
Garbage collected
Memory you no longer use is freed for you; there are no manual frees or lifetimes to manage.
Benchmarks
Performance
- Valk 0.7.6
- Go 1.27.1
- Rust 1.97.1
-
binary-tree
Allocation -
binary-tree-multi
Allocation, threads -
json
Parsing -
json-serde
Parsing -
lru
Hash map -
merkletrees
Allocation -
nsieve
Arrays -
spectral-norm
Math -
spectral-norm-multi
Math, threads
Time in seconds, lower is better. Median of 5 runs after one warm-up.
HTTP hello world
Requests per second, higher is betterValk 0.7.2 http, Rust hyper 1.11 on tokio 1.53, Go fasthttp 1.73.
Garbage collection
Milliseconds, lower is better| Scenario | Valk | Go | D | C# |
|---|---|---|---|---|
| Short-lived alloc | 9 | 74 | 131 | 78 |
| Churn with a large live set | 4 | 77 | 89 | 48 |
| Tree churn | 40 | 121 | 251 | 123 |
| Free long-lived chain | 25 | 54 | 2 | 13 |
Go 1.27.1, LDC 1.43.0, .NET 10.0.112. Median of 3 runs.
Use cases
What you can build with Valk
-
Web servers and APIs
The standard library serves HTTP/1.1 and HTTP/2, with routing, WebSockets, templates and JSON. Packages connect Postgres, MySQL, Redis and SQLite. vpkg.dev, the package registry, is a Valk web server.
HTTP servers in the docs → -
$ vman --help Valk package manager Usage: vman <command> Installs packages for a project, and the valk versions to build it with. Commands: install Install the packages of this project, or add one update Update the packages to the newest versions they allow remove Remove a package from this project versions List the versions of a package, and the valk versions they need init Write a valk.json for this project template Write starting code into this project
Command line tools
Packages parse commands, flags and arguments, and complete them in your shell. vman, Valk’s package manager, is written in Valk and can install a package’s programs for your user.
vman on GitHub ↗ -
use valk.fs use valk.json use valk.regex fn main() { let log = fs.read("access.log") ! return let re = regex.Regex.new("\" (\\d{3}) ") ! return let counts = Map[uint]{} each re.find_all(log) as m { counts[m.get(1) ?? "?"] += 1 !? 0 } println(json.from(counts).encode()) }Data and files
Regex, JSON, compression, cryptography and time zones come with the standard library. Packages add images, CSV and TOML.
Packages on vpkg.dev ↗ -
Games
Valk calls C libraries such as raylib for windows, 2D and 3D drawing, input, audio and shaders. Valkcraft, a block world game, is built this way.
Valkcraft on GitHub ↗
Built in the open.
Explore the source, follow the roadmap, or join the conversation.