AnatomyOf

Anatomy of a Nim file

example.nim
1# A minimal Nim script -- compiles to C, runs like it means it
2
3import std/strformat
4
5type
6 Robot = object
7 name: string
8 bolts: int
9
10proc beep(r: Robot) =
11 echo &"{r.name} says: BEEP. ({r.bolts} bolts remaining)"
12
13when isMainModule:
14 var wall_e = Robot(name: "WALL-E", bolts: 7) # no garbage collector jokes, please
15 beep(wall_e)
Nim is a statically typed, compiled systems programming language known for its efficiency, expressiveness, and elegance.