TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rust Devs Think We're Hopeless; Let's Prove Them Wrong (With C++ Memory Leaks)

26 点作者 zdw3 天前

7 条评论

eptcyka3 天前
Memory leaks are by far the least interesting class of defect that Rust helps with - leaking memory is safe.
评论 #43956310 未加载
评论 #43956206 未加载
评论 #43956164 未加载
评论 #43956261 未加载
linotype3 天前
I’ve seen way more comments from C++ developers complaining about Rust developers insulting them than I’ve seen Rust developers actually insulting C++. It’s weird to see how attached people are to programming languages, though it’s weird to me too how attached people are to ICE/drivetrains.
评论 #43958951 未加载
评论 #43957160 未加载
yusina3 天前
It&#x27;s 2025 and we are still discussing memory leaks. The very existence of this article is an indication that C++ (used like that) has an issue. Non-kernel programmers should not even be able to create memory leaks by mistake.<p>Well, unless they are doing something incredibly stupid including stepping over several explicit warnings of &quot;don&#x27;t do this unless you are very sure about what you are doing&quot;.
评论 #43958896 未加载
tom_3 天前
This only works with the VC++ CRT, which is potentially a bit limiting!<p>Also, the DEBUG_NEW thing is useless in practice since, from memory, it stops you using placement new, and dependencies typically don&#x27;t participate, so a zillion unlabeled leaks is the usual result from the common case of you failing to call some dependency&#x27;s free function.<p>And the allocation IDs (and therefore _CrtSetBreakAlloc) are pretty worthless in practice for multithreaded programs, because the allocation order isn&#x27;t deterministic.<p>I use the LEAK_CHECK_DF flag in the programs I write (and the CHECK_ALWAYS_DF is worth investigating too), but the only point is to indicate whether there are leaks on exit, yes&#x2F;no. If no, great; if yes, well that&#x27;s useful information, but the actual output is almost never helpful. (Though occasionally I do somehow introduce a leak from something that happens before the first thread is created.)
api3 天前
The problem with unsafe languages is not that you can’t write safe code in them with skill and discipline.<p>The problem is that programmers don’t always do that, either because they are not that experienced or they are in a hurry.<p>The real danger is when code is long lived and worked on by multiple people. One bad commit after a late night hacking session and now there is a zero day just waiting to be discovered.<p>Safe languages don’t rule that out but they make it profoundly less likely.
评论 #43956342 未加载
评论 #43956348 未加载
shmerl3 天前
No, C++ is hopeless. No need to bend over backwards to try to disprove it. It&#x27;s not only about memory safety, some of it is about legacy stuff and backwards compatibility it&#x27;s forever stuck with.
fithisux3 天前
c++ is a huge language, with lots of backwards compatibility.<p>I think c++ should keep the good modern things and fork (restart) from there by breaking backwards compatibility, c++23 will be frozen with some fixes.