1. Hello world¶
Prerequisite: follow Install, build, and run.
Create a file¶
Create hello.incn:
def main() -> None:
println("Hello, Incan!")
Coming from Python?
In Python you usually write print("..."). In Incan you have both:
println("..."): prints with a newline (used in most examples)print("..."): prints without a newline
Tip: Incan uses indentation for blocks. The canonical style is 4 spaces per indent level; run incan fmt to normalize
formatting (see: Code formatting).
Run it¶
If you installed to PATH:
incan run hello.incn
If you used the no-install fallback:
./target/release/incan run hello.incn
Try it¶
- Change the message you print.
- Print two lines (two calls to
println). - Use
print("...")once to see the “no newline” behavior.
One possible solution
def main() -> None:
print("Hello")
println(", Incan!")
println("Second line")
Next¶
Next chapter: 2. Values, variables, and types.