4 ms·
> Actually the thread was about C and someone threw Rust into the mix, as is typical. I was referring to the thread that started a conversation about pointers
by bluejekyll 8y ago
> Actually the thread was about C and someone threw Rust into the mix, as is typical.
I was referring to the thread that started a conversation about pointers and safety in Rust, not to the general post.
You are correct that C and Rust require some more bridging between the languages, but C++ also requires this when going from objects to C datatypes and vice versa. Mostly you save a little bit on the header definitions, but even there, the headers are generally #ifdef'ed to almost illegibility. With Rust's bindgen tool, getting C headers into Rust is actually quite easy: https://rust-lang-nursery.github.io/rust-bindgen/ https://rust-lang-nursery.github.io/rust-bindgen/
- blub 8y agoOk, so then we could agree that the more general general topic is safety, so different options could be discussed: D, Ada, Rust, C++, etc. The bindgen tool allows integrating C code with Rust code, which means than an existing C code base can be replaced with Rust step by step. A C code base can be compiled with some modifications as C++ and then it can be slowly refactored to use safer C++ idioms. In this case the safety improvements will be available much faster, even if the resulting code base won't be as safe as a Rust code base. The culture shock will also not be as large for the C programmers. These are non-negligible benefits, and a big reason why C code bases are moving to C++.
- stochastic_monk 8y agoThere are fewer safety guarantees even in modern C++, but there are times where Rust’s safety requirements do require slower code. Depending on why you were writing C, C++ can be the better choice, even though it can be harder. Where I stand, my biggest reason for not yet having used Rust for any projects is that the overhead for learning it outweighs what seems like a negligible gain for me when C++ already meets my needs.
- bluejekyll 8y agoStaying a little more focused, I have reasons for none of the languages you mention, but in terms of ease of integration of C and Rust, here’s one real world example: https://people.gnome.org/~federico/blog/librsvg-build-infrastructure.html https://people.gnome.org/~federico/blog/librsvg-build-infras... Which recently passed a milestone of having less C than Rust: https://www.reddit.com/r/rust/comments/8ofa0w/librsvg_has_now_more_rust_code_than_c_code/?st=JI35DG9U&sh=2e2ab3ec https://www.reddit.com/r/rust/comments/8ofa0w/librsvg_has_no... At this point I personally find it much easier to move C to Rust than C++, and end up with a much safer codebase.