News for hackers. Stuff that matters.
Re:Show HN: How to program in Rust as if it was old school C... by worldsavior on Tuesday December 20, 2022 @04:12PM (#34072654)
It's because of the libraries. They get compiled once.
Re:Show HN: How to program in Rust as if it was old school C... by steveklabnik on Tuesday December 20, 2022 @04:39PM (#34072995)
It’s because they don’t have the same semantics, you are adding overhead with the Rust version in multiple ways.
Re:Show HN: How to program in Rust as if it was old school C... by scotty79 on Tuesday December 20, 2022 @05:02PM (#34073331)
I wonder how much difference there would be if I used shared_ptr in C++ instead of the bare one.

EDIT:

As far as I can tell less than 190 lines of asm but I don't know shared_ptr enough to produce exactly the same code.

Re:Show HN: How to program in Rust as if it was old school C... by steveklabnik on Tuesday December 20, 2022 @05:45PM (#34073869)
Yeah, that gets closer for sure. refcell is still going to add a bit of state to the value inside of the allocation, but at least the shared_ptr and Rc/Arc bits are the same semantic, so it'll be closer!
Re:Show HN: How to program in Rust as if it was old school C... by worldsavior on Tuesday December 20, 2022 @06:09PM (#34074146)
Look at the asm code of rust. You would see that most of the code there is the libraries (and yeah, also because of the semantics, which are powerful).
Re:Show HN: How to program in Rust as if it was old school C... by steveklabnik on Tuesday December 20, 2022 @09:04PM (#34075824)
... the library that implements those different semantics. If you wrote your own Rc and RefCell, that code would still exist, in your crate. Where it lives isn't the root cause.