Ask HN: Why would you ever use C++ for a new project over Rust?
1–10 of 42 posts
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#2Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#3https://github.com/carbon-language/carbon-lang/blob/f9ce0b19...
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#4No.
That is part of the reason why so many big companies (Google, Microsoft, Amazon, etc.)[1][3][4] are pushing ahead on Rust adoption and large government agencies[5][6] are recommending memory safe languages over C and C++.
Google did a study and found that their Rust developers were twice as productive as their C++ developers [2].
Rust should be preferred over C++ unless you have no other choice.
[1] https://thenewstack.io/google-spends-1-million-to-make-rust-...
[2] https://www.theregister.com/2024/03/31/rust_google_c/?td=kee...
[3] https://www.theregister.com/2024/01/31/microsoft_seeks_rust_...
[4] https://blog.qwasar.io/blog/why-is-rust-growing-and-why-do-c...
[5] https://www.nsa.gov/Press-Room/Press-Releases-Statements/Pre...
[6] https://www.whitehouse.gov/wp-content/uploads/2024/02/Final-...
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#5Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#6But just like Java, its almost useless to code in it for personal or smaller projects.
For almost all of my projects where I needed performant code, the way I would do this is write it in C, and then just call the code from Python or Node. Its much easier to just focus on low level performant C code that can be written in usually one file, and then just write all the interface to it through higher level languages, especially for web frameworks.
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#7The best way to think of Rust as essentially the new Java, which sort of "won" over C++ due to its more strict syntax with mandatory OOP and code patterns. Rust enhances this by running most of the checks in the compiler so you get native code, with very few runtime additions for type safety. But just like Java, its almost useless to code in it for personal or smaller projects. For almost all of my projects where I n…
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#8>> is there ever a case for doing a project in C++ (outside of being forced by the platform you’re working on or anything outside your control)? No. That is part of the reason why so many big companies (Google, Microsoft, Amazon, etc.)[1][3][4] are pushing ahead on Rust adoption and large government agencies[5][6] are recommending memory safe languages over C and C++. Google did a study and found that their Rust deve…
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#9From Chandler Carruth who leads the C++, Clang, and LLVM teams at Google: https://github.com/carbon-language/carbon-lang/blob/f9ce0b19...
Hadn’t heard of Carbon, very cool. Super telling line with the “Developers that can use one of these existing languages should.” Thanks for sharing!
Re: Ask HN: Why would you ever use C++ for a new project over Rust?
#10The best way to think of Rust as essentially the new Java, which sort of "won" over C++ due to its more strict syntax with mandatory OOP and code patterns. Rust enhances this by running most of the checks in the compiler so you get native code, with very few runtime additions for type safety. But just like Java, its almost useless to code in it for personal or smaller projects. For almost all of my projects where I n…
That's entirely the opposite from my experience. Rust is a pleasure to code in for personal projects once you're familiar with the language, especially compared to C/C++. Managing dependencies is more straightforward, and there are a lot of crates out there to make writing your project easier.