Skip to content

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; 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 incan.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].

incan.toml
[project]
name = "hello_project"
version = "0.1.0"
requires-incan = ">=0.4.0-0,<0.5.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. 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.