hello, world

Let's start by writing a hello world program:

use std::*;

fn main() {
    println("Hello, world");
}

Save this into a file called hello.kdo

Although this seems like not much, it already uses a bunch of language features and with it a bunch of libraries:

  • core library: every project needs this library as it defines core language primitives
  • c_api library: used in-proxy by std, it defines many c ffi functions.
  • std library: this library defines println and a bunch of other useful functions and structures
    • std requires the c header stdarg.h

To compile this example we need to provide path to these libraries, located in the kdolib/ directory.

Note: Use make help or ./kommando --help to get a complete list of options

Here we assume we are in the root directory of the kommando compiler, otherwise you need to adjust the paths in the command.

./kommando hello.kdo hello -cr \ # compile + run
    ::core=kdolib/core ::core=kdolib/c_api ::core=kdolib/std \
    --include=stdarg.h

Note: Command line arguments are generally order-independant

Since this is rather verbose and inclusion of these libraries is common, there is an automatic inclusion script:

./kommando hello.kdo hello -cr $(./kdolib/link)

For even more convenience, use the included Makefile instead:

make run file=hello.kdo

Note: Use make compile or -c to compile without running.