Tutorial

This tutorial walks you through the Night language syntax, based on a minimalistic system of function declarations, type-bound variables, and simple control structures.

Hello World!

print("Hello, Night!\n");

Variables

x int = 42; y char = 'z'; name char[] = input();

User Input

print("Enter a number: "); n int = int(input());

Conditionals

if (n > 0) { print("Positive"); } else { print("Non-positive"); }

Functions

def add(x int, y int) int { return x + y; }

Loops

for (i int = 0; i < 5; i += 1) { print(i); }

Arrays

s char[] = input(); print(s[0]);

Type Checking

def is_digit(c char) bool { diff int = '9' - c; return diff >= 0 && diff <= 9; }