The Nim programming language is a compiled language, with strong static typing.
The rest of the Handbook will assume that Nim-by-example was read.
Nim can target any combination of C compiler, host OS and hardware architecture as long as the C compiler supports it.
Nim can be installed via:
- A Linux distribution package manager or Homebrew on MacOS
- Instructions at https://nim-lang.org/install.html
- Docker: https://hub.docker.com/r/nimlang/nim/
- Choosenim https://github.com/dom96/choosenim
Nim Vagrant https://github.com/status-im/nim-vagrant is unmaintained but might help setting up your own virtualized environment.
We target Nim 1.2.2 and should be compatible with the latest stable, Nim 1.2.4
Nim has unusual partial case insensitivity for identifiers. The rationales being:
- Preventing bugs when using
- Having consistent casing in a codebase even when relying on external dependencies with different casing.
The convention used in Nim-Beacon-Chain is:
snake_casefor fields and procedures names from the Ethereum spec
MACRO_CASEfor Ethereum spec constants
PascalCasefor all types (Ethereum or additional)
camelCasefor our own additional code
PascalCasefor our additional constants
In summary, we respect the Ethereum spec for Ethereum specified identifiers and use Nim NEP-1 for the rest.
By default the intermediate C code produced by the Nim compiler is available at
$HOME/.nim/compiled_project_don UNIX systems
_d indicates a debug build, the suffix
_d indicates a release build
At the time of writing, NBC targets Nim v1.2.2 compiler. The build system is at https://github.com/status-im/nimbus-build-system No patching is done at the moment on the Nim compiler, we use vanilla v1.2.2 upstream.
Nim compiler offers debug, release with
-d:release and danger with
The debug and
-d:release build differ by, the verbosity of stacktraces and passing
-O3 or equivalent to the C compiler.
Runtime checks (overflow, array bounds checks, nil checks, ...) are still included in
-d:release build. We also choose to have verbose stacktraces in NBC.
A danger build optimizes away all runtime checks and debugging help like stackframes. This might have a significant impact on performance as it may enable optimizations that were not possible like optimizing tail calls. This is not used in NBC.
Nim by example:
The Nim Manual, is a specification of how Nim should behave
- the C programmer: https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers
- Python programmer: https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers
Further resources are collected at:
- Compiler User Guide: https://nim-lang.org/docs/nimc.html