3 ms·
For a codec, WUFFS might be a better fit than Rust. https://github.com/google/wuffs https://github.com/google/wuffs In Rust, if I have two u8 variables and I a
by tialaramex 5y ago
For a codec, WUFFS might be a better fit than Rust. https://github.com/google/wuffs https://github.com/google/wuffs
In Rust, if I have two u8 variables and I add them together, Rust will try to figure out if it's sure at compile time that this is an overflow and if so reject it, but otherwise I get a binary which might have an overflow in it.
But in WUFFS when you add those variables together, WUFFS wants you to justify why that can't overflow, or, tell it that you know it does overflow and you want wrapping or whatever. As a result, WUFFS gets to be very confident the resulting (awful, machine generated) C is safe and correct.
As you observed, this sort of confidence also permits a lot of performance tricks. WUFFS has some very impressive (ie better than existing Rust code) benchmark scores for the (much simpler) codecs like JPEG or PNG but I don't think there's any reason it couldn't shoot for MPEG or beyond.
WUFFS is no rival to Rust. It doesn't have IO for example. Which is fine, your codec implementation shouldn't do IO. WUFFS deals in blobs of bytes. Bytes you got over the network or from a file go in, and bytes represented a decoded image, decompressed file, or whatever come out.