Nim compiles to C (or C++/JS) and then to a native binary. nim r hello.nim compiles and runs; nim c -d:release hello.nim builds an optimized executable.
Nim · Lesson 1 · On the house
Hello, var, let, and const
Compile and run with nim r, print with echo, and choose var, let, or const. Lesson 1 is free — on the house.
Lessons · Nim · Lesson 1 of 10 · On the house
Hello, var, let, and const
Compile and run with nim r, print with echo, and choose var, let, or const.

echo prints its arguments joined with no separator and adds a newline: echo "x = ", 5.
var is mutable, let is assigned once at runtime, const is computed at compile time.
Indentation defines blocks (spaces only). Comments start with #; #[ ... ]# spans lines.
Identifiers are style-insensitive after the first letter: myName, my_name, and myname are the same identifier.
bindings
const greeting = "hello"
let name = "nim"
var count = 1
count += 2
echo greeting, ", ", name, "! count = ", count
const squares = block:
var s = 0
for i in 1..10: s += i * i
s
echo squares
var my_value = 7
echo myValue
Quiz
Quiz
Quiz
Quiz
Check
Match the still for: Hello, var, let, and const.
Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.