What does a minimal EK9 program look like?

← Getting Started · Ref: Q1

A minimal EK9 program requires three things:
1. A module declaration (`defines module`)
2. A program construct (`defines program`)
3. A program entry point (a named function inside `defines program`)

The program name becomes the entry point. EK9 uses indentation (2 spaces) to define scope — no braces needed.

To compile and run:

  ek9 -c hello.ek9    (compile)
  ek9 hello.ek9       (run)

For the full Stdout API, run: ek9 -h Stdout

See Q3 for printing output. See Q5 for source file structure. See Q17 for entry points and defines program. See Q93 for defining classes. See Q19 for scripting.

Example

defines module qa.getting.started.minimal

  defines program
    MinimalProgram()
      stdout <- Stdout()
      stdout.println("Hello, World!")

Common mistakes

E01040 — Defining two programs with the same name in the same module triggers E01040 — duplicate type definition. Each program must have a unique name within its module. See ek9 -h E01040 for details.

Incorrect:

defines program
    MinimalProgram()
      stdout <- Stdout()
      stdout.println("Hello, World!")
    MinimalProgram()
      stdout <- Stdout()

Correct:

defines program
    MinimalProgram()
      stdout <- Stdout()
      stdout.println("Hello, World!")
Other ways to ask this
  • Hello World in EK9
  • Simplest EK9 program
  • EK9 getting started example

Coming from another language?

All — first thing everyone asks

Keywords: minimal, hello, world, start, beginner, program, intro, basic, simple, first