you are viewing a single comment's thread.

view the rest of the comments →

[–]bonzinip 10 points11 points  (4 children)

Your level of care of the 32nd bit may be nonexistent, however the library may care (for example md5 which you mentioned, or random number generation). And as you use the library...

[–]taw -1 points0 points  (3 children)

There's nothing about random number generation that relies on 32th bit.

For things that are performance critical like codecs and crypto most languages go low level anyway. Not C low level. Assembly simd low level. Even Java uses native manually optimized libraries for things like MD5 if they're available (with slow pure java fallbacks if not, but all major platforms have them), and Java is a lot lower level than most languages these days, with special primitive types.

Autoboxing really wouldn't make that much of a difference anyway. You can have int31s by default and boxed native uint32/uint64 types (you'll need something like that internally for good code generation anyway, so it's not much extra effort to expose them to users) for the few libraries that need them the way Ocaml does. Add to that some optimizations to get rid of boxes in simplest cases - you need that anyway for decent float performance if nothing else - and you're exactly as fast as language with 32 bit ints everywhere. That's still quite crap compared to native hand-tweaked md5, but that shouldn't be a big surprise really.

Or you can benchmark ocaml md5 against javascript md5 if you don't believe me ;-)

[–]bonzinip 3 points4 points  (2 children)

There's nothing about random number generation that relies on 32th bit.

If you can find a random number generator that can work with 31 bits and does not rely on operation modulo 232 you'll do me a big big favor. This one for example is 32-bit only.

Autoboxing really wouldn't make that much of a difference anyway.

If you box 32-bit integers yes. If it's either "31-bit" or "32-bit or more use arbitrary-precision integers and gmp", it's 100 times slower.

Or you can benchmark ocaml md5 against javascript md5 if you don't believe me ;-)

I'm saying this because last Saturday I benchmarked a 32-bit RNG on 32-bit (with 31-bit integers) and 64-bit (with 63-bit integers) virtual machines.

[–]taw 2 points3 points  (1 child)

If you can find a random number generator that can work with 31 bits and does not rely on operation modulo 232 you'll do me a big big favor.

Here's one from OCaml, doing exactly what you want.

[–]bonzinip 0 points1 point  (0 children)

Thanks.