Languages Features Creators Calendar CSV Resources Blog About Pricing Add Language
GitHub icon


Nim - Programming language

< >

Nim is a programming language created in 2008 by Andreas Rumpf.

#103on PLDB 15Years Old 19.1kUsers
3Books 0Papers 8kRepos

Try now: Riju · TIO

Nim (formerly named Nimrod) is an imperative, multi-paradigm, compiled programming language designed and developed by Andreas Rumpf. It is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C and compiling to JavaScript, C and C++.. Read more on Wikipedia...

Example from Compiler Explorer:
# Type your code here, or load an example. proc square(num: int): int {.exportc.} = num * num
Example from Riju:
echo "Hello, world!"
Example from hello-world:
echo("Hello World")
# Hello world in Nim echo "Hello World"
Example from Linguist:
# from: # Special configuration file for the Nim project # gc:markAndSweep hint[XDeclaredButNotUsed]:off path:"$projectPath/.." path:"$lib/packages/docutils" path:"$nim" define:useStdoutAsStdmsg symbol:nimfix define:nimfix cs:partial #define:useNodeIds define:booting define:noDocgen
Example from Wikipedia:
proc printf(formatstr: cstring) {.header: "<stdio.h>", varargs.} printf("%s %d\n", "foo", 5)

Language features

Feature Supported Token Example
Unicode Identifers
let δ = 0.00001
Booleans true false on off
 let res = true
Strings "
"Hello world"
Assignment =
MultiLine Comments #[ ]#
#[ A comment
Print() Debugging echo
Line Comments #
# A comment
Static Typing
Case Insensitive Identifiers
# Though they may be phased out:
Semantic Indentation
import macros
 result = 10
template debug*(args: varargs[string, `$`]) =
if logLevel <= Level.debug:
  const module = instantiationInfo().filename[0 .. ^5]
  echo "[$# $#][$#]: $#" % [getDateStr(), getClockStr(),
    module, join args]
Gotos X

Books about Nim from ISBNdb

title authors year publisher
Mastering Nim Rumpf, Andreas 2022 Independently published
Nim in Action Picheta, Dominik 2017 Manning Publications
Nim in Action Picheta, Dominik 2017 Manning
llvmir.html · nim.html · spss.html

View source

- Build the next great programming language · Search · v2023 · Day 205 · Docs · Acknowledgements · Traffic · Traffic Today · Mirrors · GitHub ·