Hello World
The code for a simple hello world program is as follows:
echo "Hello World"
Save this text as helloworld.nim. To compile and execute the program, the following command should be run
$ nim c -r --verbosity:0 helloworld.nim
Hello World
The command has several elements:
-
cis an alias forcompile, which compiles the Nim sources into C and then invokes the C compiler on them -
-ris an alias for--run, which runs the program -
--verbosity:0makes the compiler only output essential messages, since by default it also outputs some debugging messages. From now on, we assume that--verbosity:0is set -
./helloworld.nimis the path to the source you want to compile