3 ms·
Except you can't build a lot of those same abstractions in C, at least not in a way that doesn't involve throwing void pointers everywhere. Also the compiler ha
by mlindner 6y ago
Except you can't build a lot of those same abstractions in C, at least not in a way that doesn't involve throwing void pointers everywhere. Also the compiler has no idea what it's looking at so it can't optimize it as well because of pointer aliasing rules. So no, you can't build the same abstractions in C as cheaply as you can in Rust.
- flohofwoe 6y agoThat assumes that "abstractions" are a good thing in the first place though. I haven't seen much evidence for this assumption in real world code so far (in the context of "understanding what this piece of code actually does"). I've mainly been exposed to C++ code though (where "over-abstraction" is quite common), but I also haven't seen much Rust code so far that I would consider particularly "straightforward" and/or "readable". YMMV of course.
- steveklabnik 6y agoRust heavily relies on such things for safety checks, without loss of speed. We could get the same safety with runtime checks, but that would compromise other goals.
- gpderetta 6y agoC is an an abstraction over assembly that is an abstraction over microcode and so on and on. So C programmers must agree that some abstraction is good and it is at least plausible that C is not the best abstraction layer for evry single application.
- mlindner 6y agoIf abstractions were bad ideas we wouldn't have compilers and we'd handcode in assembly. We also wouldn't have the hardware continue to be pretending to be a PDP-8 machine even though it's completely reordering the instructions that it runs and predicting every branch taken. Our world is full of abstractions in basically every single thing we use. Also to be clear, I mean "abstractions" not "obfuscation" which many people (common in Java and C++) call "abstraction" even though it is nothing of the sort.