The standard library
Norscode has a deliberately large standard library. The goal is that ordinary tasks need no external dependency — every dependency you avoid is code you do not have to review.
Norscode has a deliberately large standard library. The goal is that ordinary tasks should not require a single external dependency — every dependency you avoid is code you do not have to review.
Modules are brought in with bruk:
bruk std.web som web
bruk std.json som json
bruk std.dato som datoWeb and networking
web · http · httpserver · url · ws · socket · tcp · dns · rest · graphql
All the way from a raw socket to a finished HTTP service with routes. The site you are reading now runs on web.
Data and storage
db · norsdb · sqlite · orm · pg · mysql · json · csv · xml
An own database (NorsDB), but also drivers for PostgreSQL and MySQL.
Cryptography and security
blake2b · sha256 · argon2id · chacha20_poly1305 · ed25519 · x509 · hmac · totp · tls13_handshake
A whole TLS 1.3 implementation, modern password hashing and two-factor. Not bindings against a C library — written in Norscode.
Text, time and files
tekst · regex · format · html · dato · tid · fil · path · zip · gzip
Collections, math and concurrency
liste · ordbok · sett · sortering · graf · math · bigint · desimal · asynk · tråd · pool
Arbitrary precision with bigint and exact decimal arithmetic with desimal — the latter is what you want for money, not floating point.
Below are the modules documented in detail. Each page shows the functions and short examples.
- std.tekststd.tekst is the toolbox for everything to do with text — searching and checking, splitting and joining, trimming whitespace, changing case, and converting to and from numbers.
- std.httpstd.http is a client for talking to other services over HTTP and HTTPS. You can fetch data, send data, and interpret the response — including JSON — without building the request by hand.
- std.dbstd.db gives you access to databases with a small, familiar set of functions: open a connection, run SQL, fetch values and rows, and control transactions.
- std.jsonstd.json lets your program speak JSON — the format nearly every web API uses to exchange data. parse turns JSON text into a map; stringify goes the other way.
- std.kryptostd.krypto gathers cryptography and security in one place: hashing, password handling, signing and verifying, random tokens and UUIDs — the right modern choices, made easy to reach.
- std.filstd.fil is the simplest layer between your program and the file system: check whether a file exists, read the whole content as text, write or append, and read and write raw bytes.
- std.webstd.web is everything you need to build web services, and the largest module in the standard library with around a hundred functions: read the request, validate it, check access, and build the response.
- std.datostd.dato works with calendar dates in a way that avoids the most common mistakes. A date is simply an integer — an ordinal counting days — so there is no time zone or clock to trip over.
- std.bytesstd.bytes works with raw byte data: a buffer of numbers between 0 and 255. It is the building block for everything that is not text — image files, data over the network, and what cryptography operates on.
- std.envstd.env reads and sets environment variables — the values the operating system or whoever starts the program gives it. It is the usual way to separate configuration from code.
- std.sorteringstd.sortering sorts lists of numbers and text. The module contains several classic algorithms — bubble, insertion and selection sort among them — in separate variants for liste_heltall and liste_tekst.