< Nimrod Programming

First steps, hello world!

So here we are let's start with our very first program, shall we? In programming languages it's been a tradition to start by writing an example of the language which displays in the console (that window with black background and white letters which seems to be from a hacker's movie) "Hello world!", and it would be like this in Nimrod:

echo ("Hello world!")

Easy, isn't it? If you want to try it just save it to a file with extension .nim (e.g: helloworld.nim) and then compile it, for doing this open a terminal, and issue in the terminal:

cd "yourPath"

Then type:

nimrod c -r "filename"

This command will make it compile, then will execute it (that's the job of the "-r" argument), when this is done you'll see in the console "Hello world!".

Understanding and extending

But how we did that? Basically we told the PC to print "Hello world!" by writing "echo" (which is what we call a function) and then telling what we wanted to print out if we wanted we could made it write other things:

echo ("It's a good day!")

But we are not limited to one expression we can put as many of them as we want:

echo ("It's a good day!")

echo ("Hello world!")

Compile this (just as we did earlier) and it'll print out into the console:

It's a good day!

Hello world!

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.