Apache License 2.0

项目介绍

sharkdp/numbat 是一个托管在 GitHub 上的开源项目,主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前获得 2.8k 个 Star、122 次 Fork。

仓库全名
sharkdp/numbat
开源许可证
Apache License 2.0
Star 数
2.8k
Fork 数
122
未关闭 Issue
133

README 摘要

[Try online!] • [Documentation] • [Tutorial] • [Syntax reference] • [Installation] • [Discord] • [Development] [Try online!]: https://numbat.dev/ [Features]: #key-features [Documentation]: https://numbat.dev/docs/ [Tutorial]: https://numbat.dev/docs/tutorial/ [Syntax reference]: https://numbat.dev/docs/examples/example-numbatsyntax/ [Installation]: https://numbat.dev/docs/cli/installation/ [Discord]…

完整内容见 GitHub 原始 README 或本页 。

常见问题

numbat 用什么语言开发?

主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前有 2.8k 个 Star。

numbat 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 numbat 的源码?

可以直接克隆仓库:git clone https://github.com/sharkdp/numbat.git,默认分支为 main;安装与运行步骤见仓库 README。

numbat 最近还在维护吗?

仓库最近一次更新为 3 周前,当前有 133 个未关闭 Issue;Star 数为 2.8k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

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

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
3087
价值分
1728
活跃状态
活跃

语言占比

CSS
HTML
JavaScript
Python
Rust
Shell
Vim Script

Release

README

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 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 (km/h or kilometer/hour, GiB or gibibytes, ° or degree, m² or m^2). New units can be introduced on the spot (unit pixel). Compatible units can be converted easily using the -> operator (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 comes with a large number of physical dimensions and units (SI, US Customary, Imperial, Nautical, Astronomical, Atomic, Nuclear, …). See this reference page for a complete overview. It also contains a lot of mathematical and physical constants as well as a large range of pre-defined functions.

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.

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 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 itself. It is therefore easily extensible by providing a init.nbt file. 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 instead.
There is no graphical user interface with buttons like x², 1/x or DEG/RAD. Qalculate! 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.

 

 

 

 

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. To contact us, either open a GitHub issue or discussion, or pop into our Discord server.

评论

暂无评论