5 ms·
To me it implies abstraction such as a constructor, but with no overhead compared to the same steps done in some other way.
by cardiffspaceman 9mo ago
To me it implies abstraction such as a constructor, but with no overhead compared to the same steps done in some other way.
- zephen 9mo agoSure, but languages and the problems we solve with them are both multifaceted, so simply pointing to one tool and saying "this is better than the one you have in your toolbox" is fine, but the plural in "zero cost abstractions" kind of implies that most or all the tools are at parity or better.
- saghm 9mo agoIt sounds like you're saying that you consider seeing this single instance of someone writing a library with a costly abstraction to be indicative of the entire language ecosystem not fitting the paradigm. This is kind of hard to take seriously; it's not like C++ doesn't have some costly abstractions as well way more embedded into the language itself (e.g. exceptions).
- zephen 9mo ago> someone writing a library with a costly abstraction That's not what happened here. > it's not like C++ doesn't have some costly abstractions This is simultaneously both completely orthogonal to my observation that the Rust FFI is borked, and a great example of a problem that wouldn't happen in C++, because in C++ you could completely ignore the costly abstractions if necessary.
- saghm 9mo ago> > someone writing a library with a costly abstraction > That's not what happened here. Yes it is. Where do you think the `FFISafe` type that they used came from? It's not anything inherent to how Rust does FFI; it's a type someone wrote in an attempt to try to provide an abstraction, and that abstraction happened to have a cost. There's absolutely no reason anyone has to use it in order to do FFI in Rust.
- zephen 9mo agoThe extra time was being taken up in the identical assembly language function. Fixing it took wizardry.
- saghm 9mo agoThe time was taken by the code around the assembly language. It was an abstraction someone wrote in a way that happened not to be efficient. The ability of someone to write a costly abstraction doesn't take away from Rust any more than the possibility of doing that in C++ would from whether C++ has them.
- Dylan16807 9mo agoIt was caused by the code around it, but the actual CPU cycles stalled out in the assembly language, making it much harder to find the problem. Is how I understood the post. Anyway there's noting wrong with rust FFI. The overhead was because this function wanted to support two options and didn't implement that in the best way.
- Aurornis 9mo ago> That's not what happened here. Yes, it's what happened here. The article is about debugging the author's own abstraction types that had some incorrect assumptions. You do not need these wrapper types to call C functions. If the author had removed the complex extractions and called the extern "C" function directly (as is standard in Rust) there would not be the additional overhead.