News for hackers. Stuff that matters.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by kllrnohj on Tuesday October 04, 2022 @03:55PM (#33085829)
> C offers total freedom in exchange for providing ways to shooting yourself in the foot. All of its "dangerous" features can be used correctly for some benefit.

C is pretty archaic in its feature set, so it's not surprising it doesn't have many language features that don't work well together since it doesn't really have any language features in the first place. That's not necessarily a good thing, either, but that's a different discussion.

> With C++ it feels like to me like that benefit is often lost entirely, and whats left is just incorrect code that for some reason passes by the compiler without error.

That's an odd statement to make here. Yes this is an unfortunate combination that results in memory leaks, but how is C's "everything is a memory leak" any better? 100% broken is better than 10% broken?

That said, I do wish C++ hadn't added coroutines in the first place. It feels like a weird addition to the language. Then again, I also wish Rust hadn't added them, either. They are nightmarishly complex in a non-GC'd language, and the benefits are far from clear. The "colored function" problem remains a hotly debated topic, and low-level, performance-focused languages (like C++ & Rust) feel like the very wrong place to hammer on those topics.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by dtgriscom on Tuesday October 04, 2022 @04:15PM (#33086097)
> Yes this is an unfortunate combination that results in memory leaks, but how is C's "everything is a memory leak" any better? 100% broken is better than 10% broken?

I'd rephrase "100% broken" as "always does what it says it will", and "10% broken" as "almost always does what it says it will." I'd prefer the former 99% of the time.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @04:57AM (#33092973)
Well, C still has plenty of undefined behaviours, that may or may not blow up on you.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by snickerbockers on Tuesday October 04, 2022 @11:43PM (#33090919)
>but how is C's "everything is a memory leak" any better?

now there's a spicy take, i've been programming in C since 2005 and i don't think i've ever heard about this "everything is a memory leak" principle.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by j-krieger on Tuesday October 04, 2022 @04:13PM (#33086070)
> That's an odd statement to make here. Yes this is an unfortunate combination that results in memory leaks, but how is C's "everything is a memory leak" any better? 100% broken is better than 10% broken?

Because if you use features that may leak memory, you can still trust yourself as a programmer. If you cant even trust the language / compiler, I would consider that worse.

> Then again, I also wish Rust hadn't added them, either

I agree.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by notacoward on Tuesday October 04, 2022 @04:54PM (#33086683)
> C's "everything is a memory leak" any better?

That's a bit hyperbolic, unless you apply the same phrase to any language (including C++) without a full tracing garbage collector or equivalent. X leaking a resource is not the same as X returning a resource that the caller is explicitly responsible for freeing. Further, C in practice is not as bad as you portray. Maintainers of large open-source projects, of which I used to be one, often define their own memory-management facilities and rules which are just as good as C++'s in preventing leaks for most code. I think they shouldn't need to nowadays, and that C would be a poor choice for a new project at any level, but that's easily shown without resorting to hyperbole.