Your First Project
Create a New Project
Section titled “Create a New Project”Chuks has a built-in project scaffolding command called chuks new:
chuks new my_projectcd my_projectThis creates a project directory with a chuks.json manifest and a src/main.chuks entry point.
Project Structure
Section titled “Project Structure”my_project/├── chuks.json # Project manifest├── src/│ └── main.chuks # Entry point└── build/ # Output directory (after build)Run Your Project
Section titled “Run Your Project”Use the VM to run your code:
chuks run src/main.chuksOr use the project-level run command, which reads the entry point from chuks.json:
chuks run-projectBuild for Production
Section titled “Build for Production”Compile to a native binary using AOT compilation:
chuks build-project./build/main.chuks.binThe resulting binary is standalone, it includes the embedded standard library and doesn’t require the Chuks runtime to be installed.
Example: A Simple HTTP API
Section titled “Example: A Simple HTTP API”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:
chuks run-projectThen visit http://localhost:3000/hello/World in your browser.
Next Steps
Section titled “Next Steps”Now that you have a project running, explore the Language Guide to learn the full language.