4 ms·
That's why modern languages that encourage type-driven development like Rust and Gleam are a godsend. Just look at the things of things you can encode in the ty
by giovannibonetti 2y ago
That's why modern languages that encourage type-driven development like Rust and Gleam are a godsend. Just look at the things of things you can encode in the type system. It can prevent issues like mixing up numbers in different units:
https://blog.hayleigh.dev/phantom-types-in-gleam https://blog.hayleigh.dev/phantom-types-in-gleam
- thesnide 2y agoTIL that it was named phantom types. I use them in C via struct/union. It is a little more verbose to use, but offers type safety when needed without any runtime penalty. That, and a good naming scheme : always encode the unit in the variable name. Always. timeout_ms is much better than timeout, unless timeout is a human readable string. Same for any config file parameter.