Getting started
Go from an empty file to a running Valk program.
On this page
Valk is a compiled language for building native applications. It combines static types with type inference, manages ordinary object memory for you, and includes coroutines and a standard library for files, networking, and more.
This guide gets the tools installed and walks through a small program. You do not need a project configuration to try a single file.
Install Valk#
On Linux, macOS, or WSL, run:
curl -sSL https://valk-lang.dev/install.sh | bash
On Windows, run this in PowerShell:
irm https://valk-lang.dev/install.ps1 | iex
The installer provides the valk compiler and vman, the toolchain and package manager. You can also use the manual downloads. Open a new terminal after installation if your shell cannot find the commands.
Write your first program#
Save the following as hello.valk:
fn main() {
let language = "Valk"
println("Hello, %language!")
}
fn main() is the program's entry point. let introduces a variable; here, the compiler infers String from the assigned value. Inside a string, %language inserts that variable's value. println writes the message followed by a newline.
Build and run it in one step:
valk build hello.valk --run
The program prints Hello, Valk!. To keep an executable, give the compiler an output path:
valk build hello.valk -o hello
Run it with ./hello on Linux or macOS, or .\hello.exe in PowerShell on Windows.
Add a little behavior#
Replace the program with this version:
fn greet(name: String) String {
return "Hello, %name!"
}
fn main() {
let names = Array[String]{ "Ada", "Sam" }
each names as name {
println(greet(name))
}
}
The greet function takes a String and returns a String. Array[String] is a growable list of strings, and each visits every name. Running the program prints a greeting for Ada, then one for Sam.
Choose your next step#
Continue with Projects & packages to organize a program across files. If you want to learn the syntax first, start with Values & types, then Control flow.
Already comfortable with the basics? Build a small HTTP server or learn to decode JSON into a class.