4 ms·
It's barely faster. I would say it's more accurate to say it's as fast as C, which is still a great achievement.
by IshKebab 2y ago
It's barely faster. I would say it's more accurate to say it's as fast as C, which is still a great achievement.
- throwaway48476 2y agoBut it is faster. The closer to theoretical maximum the smaller the gains become.
- mananaysiempre 2y agoZlib-ng is between a couple and multiple times away from the state of the art[1], it’s just that nobody has yet done the (hard) work of adjusting libdeflate[2] to a richer API than “complete buffer in, complete buffer out”. [1] https://github.com/zlib-ng/zlib-ng/issues/1486 https://github.com/zlib-ng/zlib-ng/issues/1486 [2] https://github.com/ebiggers/libdeflate https://github.com/ebiggers/libdeflate
- qweqwe14 2y ago"Barely" or not is completely irrelevant. The fact is that it's measurably faster than the C implementation with the more common parameters. So the point that you're trying to make isn't clear tbh. Also I'm pretty sure that the C implementation had more man hours put into it than the Rust one.
- bee_rider 2y agoI think that would be really hard to measure. In particular, for this sort of very optimized code, we’d want to separate out the time spent designing the algorithms (which the Rust version benefits from as well). Actually I don’t think that is possible at all (how will we separate out time spent coding experiments in C, then learning from them). Fortunately these “which language is best” SLOC measuring contests are just frivolous little things that only silly people take seriously.
- ajross 2y agoIt's... basically written in C. I'm no expert on zlib/deflate or related algorithms, but digging around https://github.com/trifectatechfoundation/zlib-rs/ https://github.com/trifectatechfoundation/zlib-rs/ almost every block with meaningful logic is marked unsafe. There's raw allocation management, raw slicing of arrays, etc... This code looks and smells like C, and very much not like rust. I don't know that this is a direct transcription of the C code, but if you were to try something like that this is sort of what it would look like. I think there's lots of value in wrapping a raw/unsafe implementation with a rust API, but that's not quite what most people think of when writing code "in rust".
- hermanradtke 2y ago> basically written in C Unsafe Rust still has to conform to many of Rust’s rules. It is meaningfully different than C.
- est31 2y agoIt has also way less tooling available than C to analyze its safety.
- nindalf 2y agoThe number of tools matters less than the quality of the tools. Rust’s inherent guarantees + miri + software verification tools mean that in practice Rust code, even with unsafe, ends up being higher quality.
- wyager 2y agoMiri is better than any C tool I'm aware of for runtime UB detection.
- est31 2y agoMiri is the closest to a UB specification for Rust that there is, coming in the form of a tool so you can run it. It's really cool but Valgrind, which is a C tool that also supports Rust, also supports Rust code that calls to C and that does I/O, both pretty common things for programs to do.