Skip to content

Your First Project

Chuks has a built-in project scaffolding command called chuks new:

Terminal window
chuks new my_project
cd my_project

This creates a project directory with a chuks.json manifest and a src/main.chuks entry point.

my_project/
├── chuks.json # Project manifest
├── src/
│ └── main.chuks # Entry point
└── build/ # Output directory (after build)

Use the VM to run your code:

Terminal window
chuks run src/main.chuks

Or use the project-level run command, which reads the entry point from chuks.json:

Terminal window
chuks run-project

Compile to a native binary using AOT compilation:

Terminal window
chuks build-project
./build/main.chuks.bin

The resulting binary is standalone, it includes the embedded standard library and doesn’t require the Chuks runtime to be installed.

Let’s build something more interesting. Replace src/main.chuks with:

import { createServer, Request, Response } from "std/http"
function main() {
var server = createServer()
server.get("/", function(req: Request, res: Response) {
res.json('{"message": "Welcome to my Chuks API!"}')
})
server.get("/hello/:name", function(req: Request, res: Response) {
var name = req.params["name"]
res.json('{"greeting": "Hello, ' + name + '!"}')
})
server.listen(3000)
println("API running on http://localhost:3000");
}

Run it:

Terminal window
chuks run-project

Then visit http://localhost:3000/hello/World in your browser.

Now that you have a project running, explore the Language Guide to learn the full language.