4 ms·
> I don’t think the Rust code could be shorter than the C++ code when converting pretty much line by line, since that leads to C++-style Rust code. I thought t
by strager 4y ago
> I don’t think the Rust code could be shorter than the C++ code when converting pretty much line by line, since that leads to C++-style Rust code.
I thought the opposite: header files (and CMakeLists.txt, which was included in the subtotal SLOC) artificially increase C++ SLOC.
> For example idiomatic Rust code can do with less defensive programming due to language features.
Can you show an example in the Rust code where this might be possible? https://github.com/quick-lint/cpp-vs-rust/tree/master/rust https://github.com/quick-lint/cpp-vs-rust/tree/master/rust
- batmansmk 4y agoJust wanted to say thank you for sharing your code! Im not familiar with C++, so Im discovering the union, UnsafeCell, ManuallyDrop and all those concepts that are rare in the Rust projects I see everyday. Im learning a lot.
- strager 4y agoYou're welcome! But maybe my code (written by a Rust newbie) isn't the best to learn from... ;P
- xiphias2 4y agoI just randomly looked at one part: linked vector. I know that the comparision here is a line by line comparison, but Rust gives a more stable interface for reusing libraries than C++. It would be a great experiment to use lots of external libraries. You might find that the code doesn't get slower (build times would probably go up though )
- strager 4y ago> I just randomly looked at one part: linked vector. How would Rust LinkedVector's implementation have fewer lines than C++'s linked_vector? > It would be a great experiment to use lots of external libraries. You might find that the code doesn't get slower (build times would probably go up though ) Build times going up is a great reason why I would not use external libraries!