Hello World in Chapel

Our first program will print the classic “hello world” message. Here’s the full source code.

writeln("hello world");

To run the program, put the code in hello-world.chpl and use the chpl compiler.

$ chpl hello-world.chpl -o hello-world
$ ./hello-world
hello world

Sometimes we’ll want to build our programs into binaries that can be executed directly. Chapel does this by default when you compile the code.

Compile the code and produce an executable file:

$ chpl hello-world.chpl -o hello-world
$ ls
hello-world  hello-world.chpl

We can then execute the built binary directly.

$ ./hello-world
hello world

Now that we can run and build basic Chapel programs, let’s learn more about the language.