3 ms·
The piece starts off with > “Numbers are just numbers, you’ll never see 0x80ULL in a .go source file”. Yet almost immediately afterward, we see the expression
by stouset 7y ago
The piece starts off with
> “Numbers are just numbers, you’ll never see 0x80ULL in a .go source file”.
Yet almost immediately afterward, we see the expression:
const uintSize = 32 << (^uint(0) >> 32 & 1)
How is `uint(0)` not just `0u` by another name? And doesn't this code snippet unnecessarily depend on specifically 32-bit and 64-bit architectures? As opposed to something like Rust's `mem::size_of::<T>()` which is both constant-time and also will "just work" on any conceivable architecture past and present?
- apta 7y agoIt's just more golang hype that people read without questioning. int and uint are just one of the many golang mistakes (ironically, another one is mentioned in the article: the way time is defined). Finally, just repeating that "golang consts are powerful" doesn't make them so.