CLI tool
sharkdp/numbat avatar
sharkdp/numbat

Numbat: a statically typed calculator language where units are types

A statically typed programming language for scientific computations with first class support for physical dimensions and units

2,693 stars115 forksRustApache-2.0

At a glance

What is it?
Numbat is a Rust-built programming language for scientific computations whose type system tracks physical dimensions. It suits engineers who want unit errors caught before the numbers are trusted, not after.
Who is it for?
Adopt Numbat if your calculations mix units and you want the dimension check to happen at parse and type-check time rather than in a spreadsheet cell you forgot to audit. Skip it if you need symbolic integration, differential equation solving, or a button-driven GUI; the README points those users to WolframAlpha and Qalculate! instead.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 36 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 24, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The unit error that survives review

Most unit bugs are not arithmetic mistakes. They are dimension mistakes: a flow rate divided by a duration, a pressure added to a length, a currency amount treated as a dimensionless number. A reviewer reading `x / y` cannot tell whether the result is a speed or an acceleration, because the code never said. Numbat's answer is to make the dimension part of the type. The README describes a static type system in which `Length` and `Time` act as types, with annotations optionally written on constants and functions and inferred when omitted. The audience is narrow and specific: people writing one-off engineering or physics calculations who want the interpreter to refuse nonsense rather than print a plausible number. It is a calculator, and the README says so explicitly under its non-features list.

Dimensions as types, units as values

The mechanism has two layers. Dimensions are the static layer: `Length`, `Time`, `Speed`, `Money`, `Frequency` are types, checked before evaluation. Units are the value layer: `km`, `kilometer`, `GiB`, `gibibytes`, `°`, `degree`, `m²`, `m^2` are all accepted spellings of the same quantity, and the README notes that units can be entered in various ways. Conversion is the `->` operator, as in `30 km/h -> mph` or `5 in + 2 ft -> cm`. Simplification is heuristic rather than symbolic: the README gives `15 km/h * 30 min = 7.5 km`, where the hour cancels against the minute and the surviving unit is chosen for readability. That heuristic is worth understanding, because it means the displayed unit is a presentation decision, not a mathematical one. The whole unit system ships as a standard library written in Numbat itself, which is why extension does not require touching Rust.

Installing Numbat and running a first calculation

The README's installation section does not carry the commands; it links to a documentation page at numbat.dev for the native command-line version. What the repository does show is the development path, which is also how you build from source. From a checkout, `cargo run -- <numbat args>` runs the CLI, and `cargo install -f --path numbat-cli` installs it. The workspace in Cargo.toml has three members: numbat, numbat-exchange-rates and numbat-cli, with numbat-wasm excluded from the workspace. Once the binary is on your path, opening it with no arguments starts a REPL, which the README describes as having command history, Ctrl-R search and tab completion.

bash
cargo install -f --path numbat-cli

At the prompt, a conversion and a compound expression look like this.

bash
30 km/h -> mph
15 km/h * 30 min

The first line should print a speed in miles per hour. The second is the README's own example and should print `7.5 km`. If you want to extend the unit system, the documented route is an `init.nbt` file, and the README's example of adding a unit is a single line.

bash
unit bathtub = 150 L

If you are editing the bundled standard library rather than your own file, the README suggests pointing `NUMBAT_MODULES_PATH` at the `numbat/modules/` folder so changes appear without recompiling, or symlinking `~/.config/numbat/modules` to that folder.

Where Numbat is the wrong tool

Numbat does not solve equations. The README states plainly that it is not a computer algebra system and does not compute integrals or solve differential equations, and it points at WolframAlpha for that. There is also no graphical interface with `x²`, `1/x` or `DEG/RAD` buttons; the README names Qalculate! for users who want graphical or text input. A third boundary is unit coverage. The standard library is large, spanning SI, US Customary, Imperial, Nautical, Astronomical, Atomic and Nuclear units, but the README concedes that if you need something more comprehensive you should contribute or use GNU units. The strictness is a trade-off in the same direction: the parser deliberately does not try to be smart about malformed input, so you get a descriptive error instead of a guess. That is the right default for a calculator whose output you intend to trust, and the wrong one if you are pasting half-formed expressions from a scratchpad and want them coerced.

How Numbat differs from GNU units and Qalculate!

The closest comparison in the README is GNU units, offered for users who need broader unit coverage. The difference is in what is being checked. A unit converter takes a value with a unit and returns a value with another unit; it has no notion of a program whose intermediate results carry dimensions through several steps. Numbat's type system is what makes `assert_eq(c, 300_000 km/s, 1% × c)` a meaningful line rather than a numeric coincidence: the dimensions have to line up before the tolerance is even considered. Qalculate! occupies a different position again, combining text and graphical input, which Numbat does not attempt. Against a general-purpose language with a units library, the distinction is that dimensions here are types the compiler enforces, not runtime objects you have to remember to construct correctly.

Maintenance, licensing and upgrade cost

The repository is not archived. The last push was on 2026-08-25, and the most recent release is v1.24.0 from 2026-08-23, following v1.23.0 in February 2026 and v1.22.0 a day before that. The release cadence visible in this list is irregular rather than steady, so pinning a version and reading the release notes before upgrading is reasonable. On licensing, the repository contains both LICENSE-APACHE and LICENSE-MIT while the project metadata lists Apache-2.0, which is the common dual-licence arrangement in Rust projects; check both files if the distinction matters to your distribution, and treat that as a question for your own legal review rather than something this article can settle. The upgrade surface is small for most users: if you only write expressions against the prelude, a version bump changes behaviour only when unit definitions or simplification heuristics change.

Editorial conclusion

Adopt Numbat if your calculations mix units and you want the dimension check to happen at parse and type-check time rather than in a spreadsheet cell you forgot to audit. Skip it if you need symbolic integration, differential equation solving, or a button-driven GUI; the README points those users to WolframAlpha and Qalculate! instead. Before committing, run the examples shipped in the repository, especially examples/custom_dimensions.nbt and examples/money.nbt, and confirm that the prelude covers the units your domain actually uses. If a unit is missing, the extension path is a single line in init.nbt, so verify that path works on your machine before you standardise on it.

Frequently asked questions

What is Numbat?

Numbat is a statically typed programming language for scientific computations with first-class support for physical dimensions and units. It runs as an interactive terminal calculator and its unit system is written in Numbat itself.

How do I install Numbat on the command line?

The README's installation section links to numbat.dev for the native command-line version. From a source checkout, the repository shows `cargo install -f --path numbat-cli` as the install command.

Can Numbat solve equations or compute integrals?

No. The README lists this under non-features: Numbat is a scientific calculator, not a computer algebra system that solves differential equations or computes integrals, and it points users to WolframAlpha for that.

How do I add a unit that is not in Numbat's standard library?

The README says the unit system is extensible through an `init.nbt` file, and gives `unit bathtub = 150 L` as an example of a one-line addition. Users can also write their own prelude module for larger changes.

Does Numbat have a graphical user interface?

No. The README states there is no GUI with buttons like `x²`, `1/x` or `DEG/RAD`, and recommends Qalculate! for users who want graphical as well as text input.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. README
  4. Releases
  5. sharkdp/numbat on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/sharkdp-numbat.svg)](https://hysenlabs.com/projects/sharkdp-numbat)