Skip to content

1. Hello world

Prerequisite: follow Install, build, and run.

Chapter 1 of 13Hello world

Create a file

Create hello.incn:

def main() -> None:
    println("Hello, Incan!")

Coming from Python?

In Python you usually write print("..."). In Incan both spellings select the same line-oriented builtin:

  • println("..."): canonical spelling used in most examples
  • print("..."): immutable alias with identical behavior

Tip: Incan uses indentation for blocks. The canonical style is 4 spaces per indent level; see the Incan Code Style Guide and run incan fmt to normalize source.

Run it

incan run hello.incn

When to make it a project

A single hello.incn file is the fastest way to try one language construct. Once you want tests, dependencies, a stable source root, release metadata, or repeatable project commands, create an Incan project:

incan new hello_project --yes
cd hello_project

This creates loaf.toml, src/main.incn, tests/test_main.incn, README.md, and .gitignore. The manifest is the project metadata file; it names the project, records the project version and toolchain requirement, and declares the default entry point under [project.scripts].

loaf.toml
[project]
name = "hello_project"
version = "0.1.0"
requires-incan = ">=0.5.0-0,<0.6.0"

[project.scripts]
main = "src/main.incn"

Run the project entry point:

incan run
incan test

For the full lifecycle workflow, see Project lifecycle.

Try it

  1. Change the message you print.
  2. Print two lines (two calls to println).
  3. Replace one call with print("...") and verify that it still prints one complete line.

One possible solution:

def main() -> None:
    print("Hello")
    println("Incan!")

If your output contains two lines and one call used print, the first chapter is complete. You have edited and run an Incan program.