Over my time developing with Motoko I haven’t landed on a general practice on when to use Nat and when not to.
Generally I tend to default to Nat/Int vs Nat8/16/32/64 unless I have a specific need, but I run into a few different issues:
- Hashing: Nat hashing doesn’t really have a default and I dont feel great about any of my implementations. A lot of the time I just convert it to a Nat32 because my numbers are rarely large, but it seems like a bad practice
- JS Client BigInt: Whenever I use Nat for api calls, its super annoying to deal with BigInt in JS, even though 99% of the time it could fit in
number
- Something else that I cant seem to remember
But Im stuck, because I could just use Nat32 everywhere by default, which would solve a lot of problems, but Nat seems to be the default things for like indexing and library usage
Im just curious on other developers best practices or any thoughts on the subject