Your First Program
Also known as: first program getting started main entry point hello world print tutorial
● Beginner5 minBefore this: InstallSpec 1.3
Write a file, run it, and turn it into a program anyone can start.
Every Kavach program starts at fn main(). The lines between its braces run from top to bottom.
fn main() {
print("namaste, duniya")
const languages = ["Kavach", "Rust", "Python"]
print(languages.len())
}The program ran and printed:
kavach run hello.kav
namaste, duniya3
Run it
Save the code as hello.kav, open a terminal in the same folder, and type kavach run hello.kav. The two lines above appear.
Make an executable
kavach build hello.kav compiles the same file to machine code and writes hello (hello.exe on Windows). That file is the whole program: give it to someone with the same kind of machine and it runs there without Kavach.
kavach run while you write, kavach build when you ship. Both give the same output.
Try it yourself
Show the answer
Replace the text inside the first print(…), keeping the quotes: print("Asha").