Getting started
This page is not available in the selected language. You are viewing the English documentation for the same version.
Install Ku first, then run ku -v (equivalent to ku --version) and confirm it reports ku 0.0.20.
Write your first program
Section titled “Write your first program”Create hello.ku with the same contents as the repository’s examples/hello.ku:
fn main() { println("Hello Ku")}fn main() is the program entry point, and println writes one line of text. This program needs no return type annotation, !, ?, or return ok(null). The entry function itself is still required. Ku does not use let or let mut.
Operations such as reading a file or parsing JSON may return a Result. Use T! and ? as explained in error handling when working with those results.
Check and run
Section titled “Check and run”From the file’s directory:
ku check hello.kuku ./hello.kucheck checks lexical, syntax, and basic semantic errors without running the program. ku ./hello.ku is equivalent to ku run ./hello.ku; Windows also accepts ku .\hello.ku. This shorthand accepts only one source-file path. The expected standard output when running is:
Hello KuIf Ku is not on PATH, invoke the executable using its full installation path. The Windows executable is ku.exe.
Variables and functions
Section titled “Variables and functions”This basic syntax fragment can be placed inside main:
name = "Ku"count:int = 3println(name)println(count)The first assignment declares a variable. An explicit type uses name:type = value. print writes without an automatic newline; println adds one.
Build an executable
Section titled “Build an executable”The installation page lists the required build tools. For the default backend:
ku build hello.kuThe default backend packages an interpreter runner. Native C compilation requires a separate C compiler:
ku build --backend c hello.kuDefault output lives under .ku/build/<profile>/; use the precise path reported by the CLI. The two backends cover different features. Passing ku check does not prove a native build will succeed.
Note: ku build --native hello.ku without -o emits C source only, without linking. Use the --backend c command above for your first compiled program.
Create a project
Section titled “Create a project”Use a built in template when you need a package directory:
ku create HelloWorld -t basiccd HelloWorldku checkku run-t is short for --template; use ku init -t basic to initialize the current empty directory. The package entry is configured in ku.mod. ku create --list lists available templates. There are currently no ku test or ku fmt commands.
Continue with the language guide, troubleshooting, and backend support.
See the CLI reference for full commands and their shorthands.