4 ms·
One of Rust's selling points is zero cost abstractions which would normally imply doing more work with less code (as you would expect in a high level language l
by Riverheart 8y ago
One of Rust's selling points is zero cost abstractions which would normally imply doing more work with less code (as you would expect in a high level language like Python). So it is surprising that it takes that many more lines of code to achieve what C does without those abstractions.
- rantanplan 8y ago"zero cost abstractions" usually means you don't pay a performance penalty for abstractions you do not use.
- tjoff 8y agoAlso means that the abstractions themselves don't introduce unnecessary overhead. It's taken from C++. C++ implementations obey the zero-overhead principle: What you don’t use, you don’t pay for [Stroustrup, 1994]. And further: What you do use, you couldn’t hand code any better. – Stroustrup https://blog.rust-lang.org/2015/05/11/traits.html https://blog.rust-lang.org/2015/05/11/traits.html
- coldtea 8y ago1300 vs 1000 is not "that many more". It's close to insignificant to comparing two languages. Especially when they boil down to things like: let ptr = unsafe { libc::mmap( ptr::null_mut(), len, libc::PROT_READ | libc::PROT_WRITE, libc::MAP_SHARED, file.as_raw_fd(), 0, ) as *mut u8 }; vs calling something like this in one line in C, etc. The C version also crams every line together, the Rust version couples related statements but leave newlines between others (not sure if loc counts those too).