News for hackers. Stuff that matters.
Re:Rust: 128 bit integers preparing to be released by Gankro on Sunday December 04, 2016 @12:54AM (#13098950)
If you can't already hash/compare an array of bytes, something terrible has happened with your language design.
Re:Rust: 128 bit integers preparing to be released by drfuchs on Sunday December 04, 2016 @01:09AM (#13098980)
Not in a way that complies into one or two machine instructions. So, your array code is an order of magnitude or two too slow. Never mind having to write it at all.

Added: I'm talking about implementing specific, optimized hash functions on 128-bit values (e.g. GUIDs, IPv6 addresses), and not generic hash functions that can take any length input (although many of them speed up linearly in the size of int that gets used internally).

Re:Rust: 128 bit integers preparing to be released by Gankro on Sunday December 04, 2016 @01:29AM (#13099032)
Rust isn't hashcode based. You don't define how to hash a type in that way. You define hashing algorithms which operate on arrays of bytes. All a type has to do to implement hashing is specify how to feed its bytes into a hasher.

Hashers provide conveniences for feeding in a u8, u16, u32, u64, etc., but most hashers just implement this as casting the value to an array of bytes and using the generic implementation. This is because most algorithms are defined in terms of bytes. Evidently there isn't any interesting optimization to do by statically knowing you have a u32 vs a u64 for these algorithms (appears to be the case for SipHash, XXHash, and Fnv).

And indeed, u128 continues this tradition in the PR: https://github.com/rust-lang/rust/pull/37900/files#diff-2327...

Re:Rust: 128 bit integers preparing to be released by dbaupp on Sunday December 04, 2016 @01:31AM (#13099034)
Whatever one can do on an i128, one can do "manually" on an array of bytes, e.g. coerce to a pair of u64s to avoid having to manipulate each byte individually.
Re:Rust: 128 bit integers preparing to be released by rickycook on Sunday December 04, 2016 @12:59AM (#13098961)
well, you can already do operations on 128bit of data that represents and int as well, but that's a kind of silly thing to say because higher level abstractions are just about making things easier. so now you can do it in 1 operation rather than several; if that's all you gain, then it's still worth it