Hello, World!
A Novis program is a text file with the extension .nvs. Create a file called hello.nvs
with these two lines:
<?nvsecho "Hello, World!\n";Hello, World!Run it:
nvs run hello.nvsnvs run checks the program first. If there is an error, it prints the error and does not
run the program.
Three things in this program:
<?nvsstarts the code. Everything after it is code until the end of the file.echowrites text. In a program you run in a terminal, the text goes to the terminal."\n"is a line break.
A program that reads the command line
Section titled “A program that reads the command line”This program says hello to the name you give it. Save it as hello.nvs again:
<?nvs// `Core\Cli::arguments()` returns the words after the file name on the command line.var $arguments = Core\Cli::arguments();
// `??` gives "World" when the list is empty.var $who = Core\Arr::first($arguments) ?? 'World';echo Core\Str::format("Hello, %s!\n", $who);Hello, World!Run it with a name after the file name:
nvs run hello.nvs AdaHello, Ada!var declares a variable. Novis gets its type from the value. Core\Str::format puts
values into a text. The compiler checks that the %s placeholders match the values.
Every function in the standard library is a method of a Core\ class. The
Core reference lists all of them.
Next: A Tour of Novis builds on this program, one step at a time.
