Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
SI
A header only C++ library that provides type safety and user defined literals for physical units (by bernedom)
Using templates I once implemented logic for dealing with SI units[1]. I also included angles, which is a bit odd but useful in practice.
It is really nice to have a type system that checks your formulas. Saved me a couple of times.
[1] https://gitlab.com/roeles/zen/-/blob/master
Now I insist on using the durationcheck lint to guard against this (https://github.com/charithe/durationcheck). It found a flaw in some exponential-backoff code I had refactored but couldn’t easily fully test that looked right but was wrong, and now I don’t think Go’s approach is reasonable anymore.
Good C++ library for that topic is [0]. You can even go further and combine with something like [1] which is super helpful for kalman filters and other stuff where you have heterogeneous units in one vector.
[0] https://github.com/mpusz/units
dimensioned[1] got me interested in Rust. I’m not far enough to recommend it, but the concept seems right.
[1] https://github.com/paholg/dimensioned
I ended up building a library for elixir a few years back for this kind of thing: https://github.com/meadsteve/unit_fun.
Go's time package is famously horrible. First they didn't expose any monotonic clocks only wall time. Then when they were forced after some public outages, like time travelling backwards for Cloudflare. They managed to fold into the original type to cling on to the "Go just works" mantra, but adding even more edge cases when exposed to the world.
https://pkg.go.dev/time#hdr-Monotonic_Clocks
> RRDNS is written in Go and uses Go’s time.Now() function to get the time. Unfortunately, this function does not guarantee monotonicity. Go currently doesn’t offer a monotonic time source (see issue 12914 for discussion).
https://blog.cloudflare.com/how-and-why-the-leap-second-affe...
> time: use monotonic clock to measure elapsed time #12914
https://github.com/golang/go/issues/12914
Yeah, before the new DateOnly (and TimeOnly) types, there was no built-in way in C# to specify a plain date. NodaTime[1] (a popular third-party library for datetime operations) did have such types though.
[1]: https://nodatime.org/
PHP mess detector has a rule for this called "Magic Number Detector" (https://github.com/povils/phpmnd) which will cause an error when it encounters numbers that violate the parameters you set.
In C++ you can use user defined literals to make the units stuff compile time checked, similar to this https://github.com/bernedom/SI for example.