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.

Circle C++ with memory safety

180 pointsby davikr12 months ago

20 comments

tialaramex12 months ago
Sean (the author of Circle) is an impressive guy. He started pursuing this work at about the same point several of the &quot;C++ Successor Languages&quot; were created, but although all of them <i>claimed</i> to be about solving this problem, especially when first announced, they actually don&#x27;t have a solution unlike this Circle work. Let me briefly enumerate:<p>Val (now HyLo) says it wants to solve this problem... but it doesn&#x27;t yet have the C++ interop stuff, so, it&#x27;s just really a completely different language nobody uses.<p>Carbon wants to ship a finished working Carbon language, then bolt on safety (somehow) but, only for some things, not data races for example, so, you still don&#x27;t actually have Rust&#x27;s Memory Safety<p>Cpp2 explicitly says it isn&#x27;t even interested in solving the problem, Herb says if he can produced measurements saying it&#x27;s &quot;safer&quot; somehow that&#x27;s good enough.<p>It&#x27;s interesting how many good ideas from Rust just come along free for the ride when you try to do this, do you like Destructive Move? Good news, that&#x27;s how you make this work in Rust so that&#x27;s how Circle does it. Exhaustive Pattern Matching? Again, Circles does that for the same reason Rust needs it.<p>It is certainly true that this is not the Only Possible Way to get Safety. It would be profoundly weird if Rust had stumbled onto such a thing, but &quot;Let&#x27;s just copy the thing that worked in Rust&quot; is somehow at once the simplest possible plan that could work <i>and</i> an astonishing achievement for one man.
评论 #40555720 未加载
评论 #40556343 未加载
评论 #40555356 未加载
jandrewrogers12 months ago
Many of the criticisms are of the C++ standard library design and implementation rather than C++ the language per se, particularly with respect to undefined behavior. Much of this, in turn, is because the C++ standard library is very old and anything new added to it must be compatible and interoperable with all of the older parts, whether or not it is a good idea. Borrow checking is a separate matter.<p>Modern C++ provides all the tools to build an alternative standard library from the ground up with most behaviors and interactions being defined and safe. This always seemed like lower-hanging fruit for a first attempt than changing the language.<p>C++ is commonly used in contexts where object lifetimes and ownership are inherently unknowable at compile-time, safety can only be determined at runtime. This is why memory safety annotations like &#x27;std::launder&#x27; exist in C++. Trying force these cases into compile-time memory safety box is a source of much friction when using languages like Rust. They handle the 80% case where compile-time safety, destructive moves, etc make things easy for the developer but then significantly worsen the complexity, and therefore safety, of the other 20%. This isn&#x27;t necessarily a bad thing but it intrinsically creates a market for C++ which explicitly allows you to handle these cases in a reasonable way.<p>Systems programming is full of edge cases that break tidy programming language models. This has to be accommodated reasonably in languages that want to wear the mantle of &quot;systems language&quot;. Zig is an example of a new systems language that does this well in my opinion.
评论 #40556803 未加载
评论 #40557505 未加载
评论 #40559181 未加载
评论 #40556863 未加载
评论 #40556663 未加载
评论 #40557271 未加载
评论 #40557158 未加载
geertj12 months ago
First came across this 2 days ago and found this extremely impressive. There&#x27;s also a YouTube presentation where Sean goes over the main features of Circle&#x27;s C++ memory: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=5Q1awoAwBgQ" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=5Q1awoAwBgQ</a>.<p>This seems to be adding Rust borrow semantics and borrow checking to C++. The delivery vehicle seems to be a C++ compiler that the author has been working on for a number of of years. I couldn&#x27;t find a ton more on the background of this.<p>From a technical perspective this looks promising as a C++ successor language. The project will have to attract other members in the C++ community though.
评论 #40555733 未加载
KerrAvon12 months ago
Haven’t read through it in enough detail yet to fully understand the language changes, but the authors are absolutely correct on some basic background that other folks don’t always understand:<p>&gt; Memory-safe languages are predicated on a basic observation of human nature: people would rather try something, and only then ask for help if it doesn&#x27;t work. For programming, this means developers try to use a library, and only then read the docs if they can&#x27;t get it to work. This has proven very dangerous, since appearing to work is not the same as working.<p>100% 100% 100%
评论 #40555437 未加载
评论 #40555360 未加载
pizlonator12 months ago
Nice to see Sean cite Fil-C, though he does it much more in passing than it deserves, considering that Fil-C gives you memory-safe C and C++ without requiring any annotations whatsoever. He cites it as a sanitizer and references undefined behavior, which isn&#x27;t really how I would describe it (unlike a sanitizer, it catches all memory safety bugs, and also unlike a sanitizer, it turns a lot of what would have been UB in C++ into defined-but-safe behavior). It&#x27;s a very different approach from Sean&#x27;s.<p>For example, Circle implies broad overhaul to tooling and libraries while Fil-C implies no such thing. Also, Circle is all about not using existing compilers on the grounds that they are hard to experiment with, while Fil-C is a surgical change to clang&#x2F;LLVM.<p>The main advantage of Circle over Fil-C is that if you pay the cost of that overhaul, you&#x27;ll get performance that is better than what Fil-C could ever do even with a lot of optimization. Not obvious to me if that makes it net better, though.
评论 #40556365 未加载
_huayra_12 months ago
Sean Baxter was on cppcast recently, highly recommend anyone interested to give it a listen: <a href="https:&#x2F;&#x2F;cppcast.com&#x2F;safe-borrow-checked-cpp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cppcast.com&#x2F;safe-borrow-checked-cpp&#x2F;</a>
quietbritishjim12 months ago
&gt; There&#x27;s only one systems-level&#x2F;non-garbage collected language that provides rigorous memory safety. That&#x27;s the Rust language.<p>Honest question: what about Ada? It was specifically designed to be a safe language for critical systems, and for a while was mandated for some military systems. Did the author not consider it, or are its protections just not as expansive as Rust&#x27;s?
评论 #40556387 未加载
评论 #40556448 未加载
madebydouglas12 months ago
It seems like if this can be the next version of C++ that would be a good thing, but if it&#x27;s just another C++ like language, such as Carbon (even with proposed benefits), aren&#x27;t we just going in circles here?<p>Wouldn&#x27;t a better approach be to instead focus on adding better C++ interop into Rust? Isn&#x27;t that a more forward thinking approach?<p>On that line of thinking, what about Swift and its C++ interop? Or is Swift not ready for systems level programming?
评论 #40558575 未加载
legobmw9912 months ago
I think a challenge to this evolution path is the same as what motivated Sutter’s cpp2: defaults<p>I think the premise that a lot of experienced programmers can write good C++ is at least somewhat valid. They know to not use raw pointers, which APIs to use for bound checking, whatever. The issue is that new users don’t, and the defaults are bad.<p>If I have to write #feature on safety in every file, it becomes possible to forget. Opting in vs opting out
mgaunard12 months ago
Memory-safe languages are IMHO a distraction from making people write bug-free code.<p>There are much more important bugs than memory safety bugs, including all sorts of performance bugs.<p>We need to address the whole spectrum instead of compromising all areas in order to tackle niche bugs that only matter in security-critical contexts.
评论 #40555883 未加载
评论 #40555772 未加载
评论 #40555838 未加载
评论 #40561763 未加载
评论 #40557296 未加载
评论 #40556117 未加载
评论 #40555812 未加载
throwawayk7h12 months ago
&gt; Institutional users of C++ should be worried. The security community is baying for this language&#x27;s extinction. The government is on our case about it, and legislation banning C++&#x27;s use in certain sectors looks like a possibility. I don&#x27;t think nitpicking the NSA is a compelling response.<p>I am a bit worried about this. should I be?
maxloh12 months ago
Also, check out Google&#x27;s in-development Carbon Language, designed to address the same issues with a Kotlin-like approach. It&#x27;s an entirely new language that could interoperate with existing C++ code&#x2F;library.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang">https:&#x2F;&#x2F;github.com&#x2F;carbon-language&#x2F;carbon-lang</a>
评论 #40557882 未加载
评论 #40555275 未加载
roca12 months ago
It&#x27;s an impressive project. One of the key problems for any safe language interoperating with C++ (even a safe C++ subset) is that you really want to be able to interact with C++ standard library types (string, vector etc) safely because they will appear at interface boundaries. Circle introduces its own safe standard library so I don&#x27;t see how Circle fares here.
Guvante12 months ago
This sounds a lot like C++&#x2F;CLI which has Microsoft backing and has a whole .NET sub language.<p>The problem was even when written together the impedance mismatch existed.
ljlolel12 months ago
Who is using Circle C++ in production?
评论 #40557248 未加载
Asooka12 months ago
I&#x27;m not sure that last paragraph had to be so toxic. We&#x27;ve had enough toxic egos in this industry, we don&#x27;t need any more. I&#x27;ve never heard of this person before, but I do not think I wish to be part of his project.
rurban12 months ago
&gt; rust: rigorous memory safety<p>&gt; circle : unsafe printf<p>Comeon people, if you allow unsafety, you cannot call your language safe. There are safe system languages, but don&#x27;t lie and call unsafe languages safe. Partial safety is not full safety.
评论 #40555650 未加载
reynmorris12 months ago
A lot of coders already do this. My STL replacement has Vector and VectorUnsafe. Vector is checked to the hilt for bounds safety, stack safety, UB safety, etc. and is slower. But if I have a tight loop, I can use VectorUnsafe and just make sure I&#x27;m being careful, and it has no checks at all.
评论 #40556094 未加载
andrewstuart12 months ago
FALSE - this is so misleading - these statements imply that 68% to 70% of ALL SECURITY ISSUES are due to memory safety - that&#x27;s wrong and those quotes leave out the important context.<p>From the post:<p><pre><code> Microsoft&#x27;s bug telemetry reveals that 70% of its vulnerabilities would be stopped by memory-safe programming languages. Google&#x27;s research has found 68% of 0day exploits are related to memory corruption. </code></pre> These sorts of false statements make people everywhere think that memory safety is a bigger issue than it is and that it impacts almost all application development which is completely wrong.
评论 #40558245 未加载
logicchains12 months ago
It&#x27;s quite ironic that on a page about safety they use an if statement without {} braces:<p><pre><code> if(x % 2) vec^.push_back(x); unsafe printf(&quot;%d\n&quot;, x); </code></pre> Skipping the braces for single line conditionals in C++ is a lazy practice that almost inevitably leads to bugs, like Apple&#x27;s famous goto fail bug: <a href="https:&#x2F;&#x2F;www.synopsys.com&#x2F;blogs&#x2F;software-security&#x2F;understanding-apple-goto-fail-vulnerability-2.html" rel="nofollow">https:&#x2F;&#x2F;www.synopsys.com&#x2F;blogs&#x2F;software-security&#x2F;understandi...</a> . While memory bugs are difficult to prevent, this particular class of logic bug can be eliminated entirely just by always remembering to write two {} around the statement, so a language concerned with correctness should promote such good practices.<p><pre><code> if(x % 2){ vec^.push_back(x); }</code></pre>
评论 #40556238 未加载
评论 #40555864 未加载