numbat

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

https://github.com/sharkdp/numbat

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 33 committers (6.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary

Keywords

calculator physics programming-language statically-typed terminal-based units web-app

Keywords from Contributors

transformers
Last synced: 4 months ago · JSON representation ·

Repository

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

Basic Info
  • Host: GitHub
  • Owner: sharkdp
  • License: apache-2.0
  • Language: Rust
  • Default Branch: master
  • Homepage: https://numbat.dev
  • Size: 12 MB
Statistics
  • Stars: 2,092
  • Watchers: 16
  • Forks: 82
  • Open Issues: 121
  • Releases: 15
Topics
calculator physics programming-language statically-typed terminal-based units web-app
Created over 3 years ago · Last pushed 4 months ago
Metadata Files
Readme License Citation

README.md

**[Try online!] • [Documentation] • [Tutorial] • [Syntax reference] • [Installation] • [Discord] • [Development]** *Numbat* is a statically typed programming language for scientific computations
with first class support for physical dimensions and units.

Key Features

Click to learn more.

Physical dimensions as types

Numbat has a static type system where physical dimensions like `Length` and `Time` act as types. Definitions of constants and functions can optionally contain type annotations that will be statically enforced. If the types are not specified, they will be inferred (`Speed`, `Money` and `Frequency` in the screenshot). See [this article](https://numbat.dev/doc/type-system.html) to learn more about Numbat's type system.
First-class physical units

Numbat is focused on computations with units. Units are therefore treated as first-class citizens. They can be [entered in various ways](https://numbat.dev/doc/unit-notation.html) (`km/h` or `kilometer/hour`, `GiB` or `gibibytes`, `°` or `degree`, `m²` or `m^2`). New units can be [introduced](https://numbat.dev/doc/unit-definitions.html) on the spot (`unit pixel`). Compatible units can be converted easily [using the `->` operator](https://numbat.dev/doc/unit-conversions.html) (`30 km/h -> mph`, `1 mrad -> degree`, `5 in + 2 ft -> cm`, `27 weeks -> days`). And unit expressions are simplified using various heuristics (`15 km/h * 30 min = 7.5 km`).
Comprehensive standard library

Numbat's [standard library](https://numbat.dev/doc/prelude.html) comes with a large number of physical dimensions and units (SI, US Customary, Imperial, Nautical, Astronomical, Atomic, Nuclear, …). See [this reference page](https://numbat.dev/doc/list-units.html) for a complete overview. It also contains a lot of [mathematical and physical constants](https://numbat.dev/doc/list-constants.html) as well as a large range of [pre-defined functions](https://numbat.dev/doc/list-functions.html).
Strict syntax

Numbat's parser never tries to be "smart" on syntactically incorrect input. This means you will either get a (descriptive) error message, or you can trust the result of your calculation.
Excellent error messages

Numbat aims to provide [descriptive and helpful error messages](https://github.com/sharkdp/numbat/blob/master/assets/numbat-error.png).
Interactive terminal

Numbat has been designed for an interactive use-case with small "one off" computations. Opening the `numbat` interpreter without any arguments starts a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) with a familiar readline interface, including all the usual features like a command history, Ctrl-R search or tab completion.
Modular and customizable

The whole system of physical dimensions and units is specified Numbat's standard library, which is [written in the Numbat language](https://github.com/sharkdp/numbat/tree/master/numbat/modules) itself. It is therefore easily extensible by [providing a `init.nbt` file](https://numbat.dev/doc/cli-customization.html). For example, a single line (`unit bathtub = 150 L`) is usually enough to add a new unit. Users can even choose to write their own `prelude` module, allowing for arbitrary modifications to the unit system.
Assertions

With its static type system, Numbat already enforces correctness of your calculations on a physical dimension level. But some checks can only be made at runtime. Numbat provides an `assert_eq` procedure that allows you to check for exact equality using `assert_eq(12 ft, 1 in)` or approximate equality using `assert_eq(c, 300_000 km/s, 1% × c)`. This can be useful to make sure that intermediate results do not change during a restructuring of your calculation.
Non-features

Numbat is a scientific calculator. It's not a computer algebra system that solves differential equations or computes intergrals. Try [WolframAlpha](http://www.wolframalpha.com/) instead.
There is no graphical user interface with buttons like `x²`, `1/x` or `DEG/RAD`. [Qalculate!](http://qalculate.github.io/) is a fantastic tool that supports both text as well as graphical input.
Numbat supports a huge range of physical units. If you need something even more comprehensive, please consider contributing. Or try [GNU units](https://www.gnu.org/software/units/).

 

 

 

 

Installation

See this page for details on how to install the native command-line version of Numbat.

Development

CICD

Run Numbat CLI cargo run -- <numbat args>

Install the CLI version cargo install -f --path numbat-cli

Run all tests cargo test

Working on the prelude

If you are working on Numbat's standard library, it is convenient to point the NUMBAT_MODULES_PATH environment variable to the numbat/modules/ folder. This way, you don't have to recompile Numbat to see your changes.

Alternatively, you can create a symlink from ~/.config/numbat/modules to the numbat/modules/ folder in the repository (see this page for the standard paths on other operating systems).

Contact us

This project is maintained by David Peter and Mads M. Jensen. To contact us, either open a GitHub issue or discussion, or pop into our Discord server.

Owner

  • Name: David Peter
  • Login: sharkdp
  • Kind: user
  • Location: Stuttgart, Germany

Citation (CITATION.cff)

cff-version: 1.2.0
title: Numbat
message: >-
  If you use this software in scientific publications,
  please consider citing it using the metadata from
  this file.
type: software
authors:
  - given-names: David
    family-names: Peter
    email: mail@david-peter.de
    orcid: 'https://orcid.org/0000-0001-7950-9915'
repository-code: 'https://github.com/sharkdp/numbat'
abstract: >-
  A statically typed programming language for scientific
  computations with first class support for physical
  dimensions and units.
license: MIT
version: 1.16.0
date-released: '2025-01-31'

GitHub Events

Total
  • Create event: 12
  • Release event: 2
  • Issues event: 78
  • Watch event: 781
  • Delete event: 10
  • Member event: 1
  • Issue comment event: 262
  • Push event: 69
  • Pull request review event: 111
  • Pull request review comment event: 86
  • Pull request event: 121
  • Fork event: 31
Last Year
  • Create event: 12
  • Release event: 2
  • Issues event: 78
  • Watch event: 781
  • Delete event: 10
  • Member event: 1
  • Issue comment event: 262
  • Push event: 69
  • Pull request review event: 111
  • Pull request review comment event: 86
  • Pull request event: 121
  • Fork event: 31

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,877
  • Total Committers: 33
  • Avg Commits per committer: 56.879
  • Development Distribution Score (DDS): 0.262
Past Year
  • Commits: 617
  • Committers: 19
  • Avg Commits per committer: 32.474
  • Development Distribution Score (DDS): 0.514
Top Committers
Name Email Commits
David Peter m****l@d****e 1,385
Robert Bennett r****t@i****m 134
Tamo t****o@m****m 62
Mads Møller Jensen m****6@g****m 61
Andrew Chin a****n@e****t 44
Bzero B****0@p****t 40
Mohammed Anas t****x@t****m 36
Hamir Mahal h****l@g****m 24
Ben Simms b****n@b****e 12
tomeichlersmith e****8@u****u 11
Valentin Le Tallec v****c@h****r 9
Manish Bhasin x****n@g****m 6
Archisman Panigrahi a****1@g****m 6
herlev u****n 6
MugheesQasim m****q@g****m 5
Marko Bausch 6****c 5
Edu e****a@p****h 5
0xflotus 0****s@g****m 5
maksimowiczm m****3@g****m 3
Ross Smyth 1****h 2
Pineapple j****4@g****m 2
0xadk 0****k 2
Guerric Chupin g****n@g****m 2
Aaron Rumpler 8****r 1
Mary Strodl i****2@g****m 1
Tiago Porsch Dopke t****h@i****m 1
Tim Voßhenrich 9****o 1
Zaidhaan Hussain z****3@g****m 1
Zengor i****a@e****r 1
hotgluebanjo 6****o 1
and 3 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 273
  • Total pull requests: 524
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 12 days
  • Total issue authors: 84
  • Total pull request authors: 51
  • Average comments per issue: 1.95
  • Average comments per pull request: 1.42
  • Merged pull requests: 413
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 80
  • Pull requests: 201
  • Average time to close issues: 12 days
  • Average time to close pull requests: 14 days
  • Issue authors: 48
  • Pull request authors: 23
  • Average comments per issue: 1.08
  • Average comments per pull request: 1.27
  • Merged pull requests: 137
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sharkdp (93)
  • rben01 (13)
  • hamirmahal (12)
  • mhmdanas (10)
  • Goju-Ryu (9)
  • irevoire (8)
  • bsidhom (8)
  • triallax (7)
  • Bzero (7)
  • archisman-panigrahi (7)
  • eminence (6)
  • joshop (5)
  • dominikh (3)
  • septatrix (3)
  • andylima (3)
Pull Request Authors
  • sharkdp (172)
  • rben01 (84)
  • hamirmahal (40)
  • Goju-Ryu (29)
  • Bzero (28)
  • irevoire (28)
  • mhmdanas (27)
  • eminence (21)
  • triallax (18)
  • P1n3appl3 (5)
  • RossSmyth (4)
  • reyalka (4)
  • t-webber (4)
  • archisman-panigrahi (4)
  • rehelmin (3)
Top Labels
Issue Labels
feature (51) good first issue (37) bug (29) question (14) type-checker (13) application (12) feature-parity (9) syntax/parser (8) prelude (7) research (7) bytecode-interpreter (4) documentation (4) performance (3) help-wanted (3) meta (2) bytecode-vm (2) web-version (2) code-maintenance (1)
Pull Request Labels
performance (2) web-version (2)

Packages

  • Total packages: 3
  • Total downloads:
    • cargo 68,904 total
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 2
    (may contain duplicates)
  • Total versions: 43
  • Total maintainers: 1
crates.io: numbat

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

  • Versions: 22
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 34,602 Total
Rankings
Stargazers count: 8.7%
Forks count: 13.5%
Average: 15.2%
Dependent repos count: 16.5%
Dependent packages count: 18.2%
Downloads: 19.1%
Maintainers (1)
Last synced: 4 months ago
crates.io: numbat-exchange-rates

A library to fetch and parse currency exchange rates from the ECB

  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 12,313 Total
Rankings
Stargazers count: 8.7%
Forks count: 13.5%
Dependent repos count: 16.5%
Dependent packages count: 18.2%
Average: 21.2%
Downloads: 49.3%
Maintainers (1)
Last synced: 4 months ago
crates.io: numbat-cli

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

  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 21,989 Total
Rankings
Dependent repos count: 30.3%
Dependent packages count: 31.7%
Average: 53.0%
Downloads: 96.9%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v3 composite
Cargo.lock cargo
  • 131 dependencies
Cargo.toml cargo
numbat/Cargo.toml cargo
  • approx 0.5 development
  • glob 0.3 development
  • codespan-reporting 0.11
  • heck 0.4.1
  • itertools 0.11
  • libc 0.2.147
  • num-integer 0.1.45
  • num-rational 0.4
  • num-traits 0.2
  • numbat-exchange-rates 0.2.0
  • pretty_dtoa 0.3
  • strsim 0.10.0
  • thiserror 1
  • unicode-ident 1.0.11
  • unicode-width 0.1.10
numbat/fuzz/Cargo.lock cargo
  • arbitrary 1.3.0
  • attohttpc 0.26.1
  • autocfg 1.1.0
  • bumpalo 3.13.0
  • bytes 1.4.0
  • cc 1.0.79
  • cfg-if 1.0.0
  • codespan-reporting 0.11.1
  • either 1.9.0
  • fnv 1.0.7
  • form_urlencoded 1.2.0
  • heck 0.4.1
  • http 0.2.9
  • idna 0.4.0
  • itertools 0.10.5
  • itoa 1.0.9
  • jobserver 0.1.26
  • js-sys 0.3.64
  • libc 0.2.147
  • libfuzzer-sys 0.4.6
  • log 0.4.19
  • memchr 2.5.0
  • num-bigint 0.4.3
  • num-integer 0.1.45
  • num-rational 0.4.1
  • num-traits 0.2.16
  • once_cell 1.18.0
  • percent-encoding 2.3.0
  • pretty_dtoa 0.3.0
  • proc-macro2 1.0.66
  • quick-xml 0.29.0
  • quote 1.0.32
  • ring 0.16.20
  • rustls 0.21.7
  • rustls-webpki 0.101.4
  • ryu_floating_decimal 0.1.0
  • sct 0.7.0
  • spin 0.5.2
  • strsim 0.10.0
  • syn 2.0.27
  • termcolor 1.2.0
  • thiserror 1.0.44
  • thiserror-impl 1.0.44
  • tinyvec 1.6.0
  • tinyvec_macros 0.1.1
  • unicode-bidi 0.3.13
  • unicode-ident 1.0.11
  • unicode-normalization 0.1.22
  • unicode-segmentation 1.10.1
  • unicode-width 0.1.10
  • untrusted 0.7.1
  • url 2.4.0
  • wasm-bindgen 0.2.87
  • wasm-bindgen-backend 0.2.87
  • wasm-bindgen-macro 0.2.87
  • wasm-bindgen-macro-support 0.2.87
  • wasm-bindgen-shared 0.2.87
  • web-sys 0.3.64
  • webpki-roots 0.25.2
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-util 0.1.5
  • winapi-x86_64-pc-windows-gnu 0.4.0
numbat/fuzz/Cargo.toml cargo
numbat-cli/Cargo.toml cargo
  • assert_cmd 2 development
  • predicates 3 development
  • anyhow 1
  • clap 4
  • colored 2
  • dirs 5
  • itertools 0.11
  • numbat 1.6.0
  • rustyline 12
numbat-exchange-rates/Cargo.toml cargo
numbat-wasm/Cargo.lock cargo
  • attohttpc 0.26.1
  • autocfg 1.1.0
  • bumpalo 3.13.0
  • bytes 1.4.0
  • cc 1.0.83
  • cfg-if 0.1.10
  • cfg-if 1.0.0
  • codespan-reporting 0.11.1
  • console_error_panic_hook 0.1.7
  • either 1.8.1
  • fnv 1.0.7
  • form_urlencoded 1.2.0
  • heck 0.4.1
  • html-escape 0.2.13
  • http 0.2.9
  • idna 0.4.0
  • itertools 0.10.5
  • itoa 1.0.9
  • js-sys 0.3.64
  • libc 0.2.147
  • log 0.4.19
  • memchr 2.6.3
  • memory_units 0.4.0
  • num-bigint 0.4.3
  • num-integer 0.1.45
  • num-rational 0.4.1
  • num-traits 0.2.15
  • once_cell 1.18.0
  • percent-encoding 2.3.0
  • pretty_dtoa 0.3.0
  • proc-macro2 1.0.63
  • quick-xml 0.29.0
  • quote 1.0.29
  • ring 0.16.20
  • rustls 0.21.7
  • rustls-webpki 0.101.4
  • ryu_floating_decimal 0.1.0
  • scoped-tls 1.0.1
  • sct 0.7.0
  • spin 0.5.2
  • strsim 0.10.0
  • syn 2.0.23
  • termcolor 1.3.0
  • thiserror 1.0.40
  • thiserror-impl 1.0.40
  • tinyvec 1.6.0
  • tinyvec_macros 0.1.1
  • unicode-bidi 0.3.13
  • unicode-ident 1.0.11
  • unicode-normalization 0.1.22
  • unicode-segmentation 1.10.1
  • unicode-width 0.1.10
  • untrusted 0.7.1
  • url 2.4.1
  • utf8-width 0.1.6
  • wasm-bindgen 0.2.87
  • wasm-bindgen-backend 0.2.87
  • wasm-bindgen-futures 0.4.37
  • wasm-bindgen-macro 0.2.87
  • wasm-bindgen-macro-support 0.2.87
  • wasm-bindgen-shared 0.2.87
  • wasm-bindgen-test 0.3.37
  • wasm-bindgen-test-macro 0.3.37
  • web-sys 0.3.64
  • webpki-roots 0.25.2
  • wee_alloc 0.4.5
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-util 0.1.5
  • winapi-x86_64-pc-windows-gnu 0.4.0
numbat-wasm/Cargo.toml cargo
  • wasm-bindgen-test 0.3.13 development
  • codespan-reporting 0.11.1
  • console_error_panic_hook 0.1.6
  • html-escape 0.2.13
  • termcolor 1.3.0
  • wasm-bindgen 0.2.63
  • wee_alloc 0.4.5
numbat-wasm/www/package-lock.json npm
  • 565 dependencies
numbat-wasm/www/package.json npm
  • copy-webpack-plugin ^5.0.0 development
  • numbat-wasm file:../pkg development
  • webpack ^4.29.3 development
  • webpack-cli ^3.1.0 development
  • webpack-dev-server ^3.1.5 development
vscode-extension/package.json npm