Start with INSTALL.md for the source installation, LLVM tools, PATH setup and first program.
Save the npkbuild helper from its first-program section.
For hello.npk, use:
npkbuild hello
./helloRead these guides in order, saving the driver guide (3) for after page 6:
- Quick start: a first program, bindings, functions and
Result, errors andfailsafe, control flow, structs, and a library import. - Cheat sheet: short examples of calls, operators, types and literals.
- Driver guide: an advanced page, best read after page 6, once you know the language basics. It covers the SDK header, C build setup, library paths, and a Nitpick client with a C driver.
- Numbers: integer types, overflow and wrapping,
tbb, wide integers, floats,frac,tfp, the two casts, and the rounding rules. - Errors and failsafe: functions that can fail and their
Result,?|,?!,rawandrelay, setting a result aside, declaring errors,failsafe, anddefer. - Control flow:
ifand theisternary,pickwith ranges, guards andfall, the loopswhile,for,till,loopandwhen, labelledbreakandcontinue,exit, and which loop to use. - Structs and enums: declaring and making a struct, fields, structs as parameters and results,
fixed, a field withlimit<Rules>, enums with tags or data, and why apickover an enum must cover every variant. - Strings and moves: a
stringowns its text, why=doesn't copy one,.clone(), comparing with.eqand ordering with.cmp, lending a string to a function, handing it over withmove, and structs with astringfield. - Arrays and lists: fixed-size arrays and their length, reading and writing an element, looping over an array, an index out of range, the growable
List<T>, arrays of plain structs, and passing arrays and lists to functions. - Modules: a program in several files, the ways to import, what
pubexposes and what stays private, re-exporting withpub use, sharing a struct and a rule, errors across modules, import cycles, and name clashes. - Generics and traits: one function for several types, a struct for several types, when to write
::<T>, traits and theirimpl, bounds such asT: Shape, why a generic body may use only what its bounds give, and the refusals of common mistakes. - Ternary and nonary numbers: balanced ternary and nonary digits and place values, the types
trit,tryte,nitandnyte, their literals, arithmetic andERR, three-valued logic, reading one digit, and casts.
The guides and examples come from the public documentation repository, on branch main, with the guides at its top level.
Clone it beside the compiler clone, so that nitpick/ and nitpick-docs/ share a parent folder.
For the hello example, work in examples/01_hello/: run npkbuild hello, then ./hello.
See the driver guide for examples/02_driver/ and its build commands.
See contracts for requires, ensures, and the checks Z3 can prove.
See limits for rules on locals, parameters and struct fields.
For further reading, see the reference files in meta/specs/ in the compiler clone (nitpick/).
Editor highlighting for VS Code, nano, vim and Emacs is in nitpick-tools.
The guides were checked against compiler commit 64861f8, and again at 226ebb99 (the quick start, the cheat sheet, and the driver guide's caution note and example). The numbers and errors pages were checked at 3a45b7c4. Each example page names the commit it was checked against.