4 ms·
I recently had to write a bunch of custom linked list like structures in C++. Seeing how Rust adds that big heap of complicated boiler plate on top of the actua
by gmueckl 8y ago
I recently had to write a bunch of custom linked list like structures in C++. Seeing how Rust adds that big heap of complicated boiler plate on top of the actual algorithms doesn't exactly make me a fan of that language.
- baq 8y agono double delete and no dangling pointers is the tradeoff. i once spent two 12h long days hunting a dangling pointer. it was fun finding it, that one time.
- the_mitsuhiko 8y agoIf all you want is the C++ experience there is no complicated boilerplate.
- gmueckl 8y agoThere is so many ways you can write good C++ code. It depends on the use case. I have code that is nice, modern and concise and I have code where I recently threw all of that out and even introduced custom containers and custom memory management to get an important 2x to 3x speedup.
- monocasa 8y agoIt's not 'boilerplate', and rust is remarkably good at removing boilerplate. It's that in this case, what you've described as "the actual algorithms" is only a small part of the semantics that are provided by a safe, generic data structure under Rust. If you want to ignore all of that and only want the C++ level of semantics, writing the code in unsafe blocks is all you need to do.
- gmueckl 8y agoIf I have to write in unsafe blocks, then what is the point? I get the intent to prove memory accesses to be correct during compilation. But if a simple linked list turns into a nightmare project then I get the feeling that this language has missed the mark on usability as a systems language.
- monocasa 8y agoThe thing is, that proving that the interface for "a simple linked list" is safe is actually nontrivial. It's not something that translates into day to day Rust. It's just a different language, different parts are hard (most parts are easier IMO). Picking off a linked list just happens to be one of the hardest pieces.