TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why would you ever use C++ for a new project over Rust?

32 pointsby rbnslabout 1 year ago
Was having this debate with a coworker recently who’s a Rust fanatic and prior C++ eng; he said the tooling and support has gotten so good you would just be shooting yourself in the foot if you ever started something new on C++. I wasn’t convinced but is this really the case? Like if you had equal skill in both, 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)?

14 comments

cyber_kinetistabout 1 year ago
If you want to create any real-time graphics application (video games, game engines, CAD software, visualization, etc.), or do any sort of scientific computing &#x2F; HPC. The graphics ecosystem in Rust is still too undeveloped to see adoption (for the graphics API people are converging towards WebGPU, but it&#x27;s still no match to Vulkan &#x2F; DX12 &#x2F; Metal), same goes for any GPGPU computing. Rust is also currently lacking in desktop GUI development (though nowadays Slint is trying to catch up with Qt!)<p>And in the case of apps where objects can have very dynamic lifetimes (like game engines or CAD), the borrow checker wouldn&#x27;t really help with you that much since you would have to manage these with reference counting or some other way anyway (ex. arena allocation + generational indices).<p>What Rust excels over C++ at this point is just sane defaults &#x2F; less footguns (no uninitialized memory, bounds checking even in release mode) as well as some language niceties, but Rust has its own issues for pragmatic usage (slow compilation, lackluster libraries, cumbersome to interface with C APIs, ...)
评论 #39929611 未加载
评论 #39907658 未加载
tamarlikesdataabout 1 year ago
It boils down to a few key points:<p>Mature Libraries: C++ has a treasure trove of well-established libraries. For niche or legacy needs, C++ might be your only option. Performance Control: When you need to micro-manage performance, C++ gives you the nitty-gritty control that can make all the difference. Industry Norms: In some fields like game development, C++ isn&#x27;t just preferred, it&#x27;s expected. Sticking to industry norms can sometimes outweigh the benefits of newer tech. So, while Rust has its perks, especially around safety and concurrency, C++ still holds its ground where its deep-rooted ecosystem and granular performance control come into play.
thesuperbigfrogabout 1 year ago
&gt;&gt; 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)?<p>No.<p>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++.<p>Google did a study and found that their Rust developers were twice as productive as their C++ developers [2].<p>Rust should be preferred over C++ unless you have no other choice.<p>[1] <a href="https:&#x2F;&#x2F;thenewstack.io&#x2F;google-spends-1-million-to-make-rust-c-interoperable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;thenewstack.io&#x2F;google-spends-1-million-to-make-rust-...</a><p>[2] <a href="https:&#x2F;&#x2F;www.theregister.com&#x2F;2024&#x2F;03&#x2F;31&#x2F;rust_google_c&#x2F;?td=keepreading" rel="nofollow">https:&#x2F;&#x2F;www.theregister.com&#x2F;2024&#x2F;03&#x2F;31&#x2F;rust_google_c&#x2F;?td=kee...</a><p>[3] <a href="https:&#x2F;&#x2F;www.theregister.com&#x2F;2024&#x2F;01&#x2F;31&#x2F;microsoft_seeks_rust_developers&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.theregister.com&#x2F;2024&#x2F;01&#x2F;31&#x2F;microsoft_seeks_rust_...</a><p>[4] <a href="https:&#x2F;&#x2F;blog.qwasar.io&#x2F;blog&#x2F;why-is-rust-growing-and-why-do-companies-like-rust" rel="nofollow">https:&#x2F;&#x2F;blog.qwasar.io&#x2F;blog&#x2F;why-is-rust-growing-and-why-do-c...</a><p>[5] <a href="https:&#x2F;&#x2F;www.nsa.gov&#x2F;Press-Room&#x2F;Press-Releases-Statements&#x2F;Press-Release-View&#x2F;Article&#x2F;3608324&#x2F;us-and-international-partners-issue-recommendations-to-secure-software-products&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.nsa.gov&#x2F;Press-Room&#x2F;Press-Releases-Statements&#x2F;Pre...</a><p>[6] <a href="https:&#x2F;&#x2F;www.whitehouse.gov&#x2F;wp-content&#x2F;uploads&#x2F;2024&#x2F;02&#x2F;Final-ONCD-Technical-Report.pdf" rel="nofollow">https:&#x2F;&#x2F;www.whitehouse.gov&#x2F;wp-content&#x2F;uploads&#x2F;2024&#x2F;02&#x2F;Final-...</a>
评论 #39901218 未加载
评论 #39900708 未加载
torranceabout 1 year ago
If your project depends heavily on general purpose GPU programming, you might start one in C++.<p>This was the case for a project I am working on that was started in the last year. The interop features in rust (and other languages) are simply not as reliable as writing kernels directly in CUDA or HIP or even DPC++. You _can_ attempt to write the GPU code in C++ and call to this from $LANG via ffi, but if you want to preserve data structures and methods to work on both the host and device, its still easier to write it once in C++.
评论 #39929634 未加载
justin66about 1 year ago
Rust doesn’t even have a real GUI library yet, let alone support from common game libraries. C++ supports a hundred times as many compilation targets and platforms.
评论 #39901610 未加载
评论 #39902292 未加载
评论 #39903583 未加载
评论 #39929645 未加载
评论 #39901402 未加载
Avamanderabout 1 year ago
I&#x27;ve personally stumbled upon two - obscure hardware and GUIs.<p>It&#x27;s really difficult to evaluate a hardware product with only a C(++) SDK using only Rust. There are of course ways around this but those are a significant amount of effort.<p>In terms of GUIs - there&#x27;s simply no &quot;Qt-Rust&quot; that would work in a Rust-y way without causing massive headaches. Handling all that state is incredibly difficult in Rust, at least for me (but I recall others describing why as well).
评论 #39909102 未加载
评论 #39909092 未加载
frankjrabout 1 year ago
From Chandler Carruth who leads the C++, Clang, and LLVM teams at Google:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang&#x2F;blob&#x2F;f9ce0b194dff0d9950ce80183df9e63a6fb70d13&#x2F;README.md#why-build-carbon">https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang&#x2F;blob&#x2F;f9ce0b19...</a>
评论 #39900733 未加载
jollyllamaabout 1 year ago
Existing base of experienced developers
thorinabout 1 year ago
If you spent 10-20 years writing C++ and all of the code you interact with is written in C++ and all the libraries you are calling are C++, why would you write in Rust?
yurisobigabout 1 year ago
Haven&#x27;t really dived into Rust yet because its syntax looks a bit ugly to me. But yeah if I have to choose between Rust and C++, I would be happy to try Rust if there is a library&#x2F;framework in Rust that does a better job.
JohnFenabout 1 year ago
If I had complete freedom to choose, I&#x27;d choose C++ simply because I find programming in Rust to be very unpleasant.
colundabout 1 year ago
I would use it for cross platform native ui development with wxWidgets
hulituabout 1 year ago
Because for a particular rust file, you need a particular conpiler version ? &#x2F;s<p>Does Firefox compile with the shipped rust compiler ?
ActorNightlyabout 1 year ago
The best way to think of Rust as essentially the new Java, which sort of &quot;won&quot; 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.<p>But just like Java, its almost useless to code in it for personal or smaller projects.<p>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.
评论 #39900832 未加载
评论 #39900537 未加载
评论 #39903068 未加载
评论 #39907686 未加载