NouvaLang v0.1.0
GitHub

First Program: Printing (print)

Writing and executing your very first NouvaLang program using the built-in print function.


1. The Classic Hello World

In NouvaLang, console output is performed using the built-in print(...) function. Let's write the quintessential first program:

print("Hello, World!");

To run this code immediately in the interactive shell:

$ ./nouva
nouva> print("Hello, World!");
Hello, World!
null
Why does it return null?

In NouvaLang, all functions produce a return value. When print(...) finishes writing to the terminal, it evaluates to null.


2. Printing Different Data Types

print can display any primitive type without requiring manual conversion:

// Printing Integers
print(42);

// Printing Floating-point numbers
print(3.14159);

// Printing Booleans
print(true);
print(false);

3. Multiple Arguments (Variadic Printing)

You can pass multiple comma-separated arguments of different types into a single print call. Nouva formats and outputs them separated by a space:

let language: str = "Nouva";
let version: float = 0.1;
let is_ready: bool = true;

print("Welcome to", language, "version", version, "| Ready:", is_ready);
// Output: Welcome to Nouva version 0.1 | Ready: true

4. String Concatenation vs Comma Separation

You have two clear ways to combine output in Nouva:

let user: str = "Mohamed";
let id: int = 1001;

// Method 1: Variadic arguments (automatically space-separated)
print("User:", user, "ID:", id);

// Method 2: String concatenation using the '+' operator with explicit type casting ('as str')
print("User: " + user + " (ID: " + (id as str) + ")");