HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
SciNim
Unchained
Nim2021–2025
SciNim / Unchained

Unchained

A fully type safe, compile time only units library.

3Distinct people
10Mentions
0Explicit recommenders
122GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A fully type safe, compile time only units library.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year10 dated mentions

Observed mentions: 2021-05-11 08:51:02 UTC to 2025-10-04 23:25:24 UTC.

02462021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 6 mentions; 0 submissions, 6 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC606
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC000
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

What Hacker News says

10 sources
Nim (https://nim-lang.org), mentioned elsethread Re: numeric ranges like Ada, only needs a library for this: https://github.com/SciNim/Unchained FWIW, physical dimensions like meters were the original apples-to-oranges type system that pre-dates all modern notions of things beyond arithmetic. I'm a little surprised it wasn't added to early FORTRAN. In a different timeline, maybe. :) I think what is in "the" "stdlib" or not is a tricky question. For most general/general purpose languages, it can be pretty hard to know even the probability distribution of use cases. So, it's important to keep multiple/broad perspectives in mind as your "I may be biased" disclaimer. I don't like the modern (well, it kind of started with CTAN where the micros seemed meant more for copy-paste and then CPAN where it was not meant for that) trend toward doz
Read the rest
ens to hundreds of micro-dependencies, either, though. I think Python, Node/JS, and Rust are all known for this.
In A comparison of Ada and Rust, using solutions to the Advent of Code
Or you could just use Nim [0], where this sort of thing can be implemented in Nim's macro system. Then you have a regular programming language combined with CT safe units. :) It even pretty much looks identical to those Numbat snippets! import unchained let earth_mass = 5.972168e24.kg let solar_mass = 1.9885e30.kg let lunar_mass = 7.342e22.kg let distance_sun = 1.AU # astronomical unit let distance_moon = 384_400.km let force_sun = G_Newton * earth_mass * solar_mass / distance_sun let force_moon = G_Newton * earth_mass * lunar_mass / distance_moon echo force_sun / force_moon # 69593.6 UnitLess Sorry for the shameless plug. ;) Numbat looks quite cool though and the article talks about a lot of things to think about when writing such a program / lib / programming language. [0]:
Read the rest
In Show HN: Numbat – A programming language with physical dimensions as types
Yes. The kind of type modeling this is doing is not very physics-unit-minded at all (where any multiplicative operation potentially creates a new type). Rather, it is trying to prevent non-additive (add/subtract/compare) operations bugs viewed as common/high risk. I mean, your example in the context of these dim.analysis discussions would really have an output type of DurationSquared, not Duration which is what usual prog.lang modeling does for arithmetic ops. Go also is not alone. E.g., the Nim std/times has a `*` defined for (int, Duration) but not (float, Duration). Personally, I suspect prog.langs with native 64-bit ints are better off just using raw nanoseconds for this kind of thing (even time since the epoch gets you into Star Trek centuries.. something like 10 human generations from now). In terms of the type creation, though,
Read the rest
there is some hope like the Nim Unchained package: https://github.com/SciNim/Unchained
In A mathematical formalization of dimensional analysis (2012)
Anything with a finite (200 is small even) number of units misses the algebraic structure of the problem mentioned in https://news.ycombinator.com/item?id=36988497 wherein multiplying|dividing two things gives you a (potentially) new unit which implies an open ended "space" of units. To be concrete (hah!), in C++ a template meta-type with 12 signed integer parameters (6 numerators & 6 denominators for rational exponents of SI base units) might be one way to model it. Unlike C++ template stuff, Nim macros (like Lisp macros) makes metaprogramming more like procedural programming - just against abstract syntax trees. I think that helps to shield some of this type complexity from users, but the documentation README https://github.com/SciNim/Unchained does better job than I can in an HN comment. Of course, for unit system conversion, the numb
Read the rest
er of dimensions (6 in SI, 3 in CGS/Gaussian) changes. So, for full generality you need compile-time (if you want static type integration/CT errors) linear algebra over a rational field (at least & conventionally) to project|inverse project. That might be theoretically possible in C++. I would think it very un-fun and unlikely to ever have been done. There's probably a Mathematica package, though. EDIT: It seems that mp-units mentioned in a sibling comment has some rare support for varying unit systems (no GR or Planck ones, but at least "natural" & "hep" & not sure about system-conversion or just system-use). That lib also leans very heavily on many very modern C++ (C++20 & beyond) features, has constexpr everywhere in use cases. I am not sure I would say it shields users wonderfully or makes it seem like units are very ordinary types. Just looking at mp-units/example/VARIOUS.cpp makes it look syntactically very noisy, verbose, and a lot to learn.
In GNU Units
Yes - you haven't seen the full scope until you confront unit system conversions as alluded to in my other comment (https://news.ycombinator.com/item?id=36988497). There should also be conversions to/from SI|CGS and "natural units" (particle physics) and "gravitational units" (general relativity - G=c=1). The "input/output" can be a bit more subtle, too - since you may need to tell the converter the abstract physical kind/"meta type" of the thing like "energy" or "momentum" or "charge" to fully define what might happen (and in some ideal world get back an expression with powers of G's and c's in there symbolically rather than only numerically). Some of this shows up in an unresolved issue on that Nim library I mentioned[1]: https://github.com/SciNim/Unchained/issues/8 EDIT: { One reason to preserve a symbolic capability is that some cons
Read the rest
tants have resisted precise measurement for centuries - G is still only known to about 5 decimals [2] - and you don't want round-trip unit conversion to add such errors to the calculation. } [1] https://news.ycombinator.com/item?id=36988225 [2] https://en.wikipedia.org/wiki/Gravitational_constant#Modern_...
In GNU Units
Units of measure are, of course, the aboriginal type system for pre-software hand calculation.. carrying units along to make sure you do not add apples to oranges { unless you know how to convert "apples" to "oranges" for some adapted metaphorical fruits.. e.g. orange section/segment/slices :-) }. Nim [1] has sufficient compile-time strength that units can be integrated with the static type system: https://github.com/SciNim/Unchained [1] https://nim-lang.org/
In GNU Units
I've recently written a units library for Nim [0]. It's still WIP, but it's already proven extremely useful for me as a physicist. Thanks to Nim's strong type system and metaprogramming features, it allows for a fully compile time design, without any runtime overhead (in form of special unit objects or such things; everything is a `distinct float`). In addition Nim's unicode support, the code even looks nice! A more complex use case (I can link more if desired): [1] [0]: https://github.com/SciNim/Unchained/ [1]: https://github.com/SciNim/Unchained/tree/master/examples
In Atlas, a hopefully better engineering IDE

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.