Germanysharkdp/numbat
A statically typed programming language for scientific computations with first class support for physical dimensions and units
Featured achievements
The project's latest awards
#1 Repository of the week
#1 Repository of the week
#1 Repository of the week
📐 Numbat: units baked into the type system
Stop mixing meters and seconds by accident.
Numbat is a statically typed programming language built for scientific computations with first-class support for physical dimensions and units. Designed mainly for the interactive terminal, it aims to catch unit and dimension mistakes at compile time instead of by hand.
✨ Highlights
- Physical dimensions as types:
Length,Timeand others act as types. Annotations can be added, or dimensions likeSpeedare inferred automatically. - First-class units: Units can be entered in many forms (
km/h,kilometer/hour,GiB,°,m²). Compatible units convert with the->operator, and expressions like15 km/h * 30 minare simplified to7.5 km. - Comprehensive standard library: Covers SI, US Customary, Imperial, Nautical, Astronomical, Atomic, Nuclear and more, with physical constants and pre-defined functions.
- Strict syntax: The parser never guesses on invalid input. Either it gives a descriptive error, or the result can be trusted.
- Clear error messages: Focuses on helpful errors to point out type or unit mismatches.
- Interactive REPL: Runs in the terminal with readline features like command history, Ctrl-R search and tab completion for quick, one-off calculations.
- Modular and extensible: The entire unit and dimension system is written in Numbat itself. New units can be added via
init.nbtor by swapping the prelude entirely. - Assertions: Use
assert_eqfor exact or approximate checks, e.g.assert_eq(c, 300_000 km/s, 1% × c), to verify calculations during restructuring.
💡 Why it matters
By making physical dimensions part of the type system, Numbat shifts unit safety from manual tracking to static checks. Since the prelude is itself Numbat code, extending the unit system stays minimal and consistent with the rest of the language. It's best for scientific work, engineering checks, and any calculation where mixing incompatible units would be costly.
#Calculator #Units #Physics #ProgrammingLanguage #StaticallyTyped #TiniX
Similar Projects
Discover other similar projects and AI models.
Reverse engineer anything with agents, from app behavior down to native binaries.
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
Python tool for converting files and office documents to Markdown.
🙃 A delightful, community-driven framework for managing your zsh configuration. Built by 2,600+ contributors, with hundreds of plugins (git, rails, laravel, node, python, docker, kubectl, aws, and more), themes to spice up your terminal, and automatic updates to keep your command line feeling like home.