News for hackers. Stuff that matters.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by j-krieger on Tuesday October 04, 2022 @03:01PM (#33085102)
Putting the discussion about C++ memory safety and concurrency issues aside, I am pretty astonished that C++ continues to include bugs where you have two actual language features - not library functions - which on their own work perfectly fine, but combining the two makes the entire thing silently implode.

I am trying very hard to imagine any other higher level language where two distinct language features, each used correctly in their own way, can not be safely combined. The only thing that comes to mind are python's default parameters and passing an empty list as one.

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. 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.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by selimnairb on Tuesday October 04, 2022 @03:49PM (#33085756)
I have returned to using C++ over the last six-months after not using it really since university 20+ years ago. I mostly write Python these days, Java in the past, but have also recently written some moderately complex and unsafe C (e.g., making a parser using flex and bison; doing lots of void* pointer arithmetic to get around not having runtime reflection). I am astonished at the complexity of modern C++. I’ve studied Rust and used some Swift (on an iOS app for a client a couple of years back), and I struggle to “correctly” write code in C++. I feel as if C++ is collapsing under its own weight.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by curtis3389 on Tuesday October 04, 2022 @04:16PM (#33086133)
I programmed in C++ all through college, and I get the same feeling watching its development.

TR1 brought the language to a pretty good place with smart pointers, and at first C++11 looked awesome with its type inference features and range-based for loops.

But, also in C++11 were tons of weird gotchas with new and old features. The one that comes to mind is the uniform initialization. It was supposed to fix the issues with calling regular constructors, so you could just use the new syntax and not worry.

But, they also added initializer lists, and those have issues with uniform initialization, so now you not only need to know all the pre-existing issues with the old syntax, you need to know the new syntax and its issues.

This all comes back to C++ refusing to break backwards compatibility, which is great and all, but at this point they've made a language that is only good for job security.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by qwertox on Tuesday October 04, 2022 @07:26PM (#33088591)
I started programming with C and C++ in the 90s and I absolutely loved it. Then big projects with multithreading started to blow up because it became to complex to manage. 2010 I started with Python and absolutely fell in love. Since then I've been using it and never regretted it, until I had to upgrade servers and with it migrate from 2.7 to 3.8, now again to 3.10. There are issues with these migrations which aren't negletible if you're running over 50 different servers, doing different things, where suddenly for no reason at all a function parameter gets removed from some asyncio function, or all the virtualenvs are no longer usable because they were set up with 3.8, which got replaced by 3.10. This makes upgrading an OS very painful as it requires many weeks of preparation, which is something you first need to become aware if. I now have tooling which monitors every running Python process and prints out which modules are used an other things, because there was so much to look after. Basically each Python script has to register it's execution at a central server, but because it can be down, they have to use a local caching proxy server for this.

Then again, two weeks ago I started learning Rust and I'm absolutely blown away. I'm completely absorbed by it. I'm now thinking of migrating some of the Python projects to Rust so that I can have a single executable which I can then copy around without having to care about virtual environments. I mean, I loved C and C++ for its precision, and love Python for it's liveliness (I use `reload` a lot so all the projects are living things which support hot reloading), but Rust seems to hit the sweet spot between C++ and Python. Between performance and little dependencies due to the lack of an interpreter, and a somewhat easy to use threading and async / await with Tokio, with all the safety guarantees Rust offers. I'm currently in heaven for this and I hope it lasts.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @04:49AM (#33092931)
It's probably best not to run Python bare-metal on your operating system. Or at least not to rely on your operating system's Python.

Use a Python package manager, and/or run your Python processes in containers.

That way you can upgrade your OS without having to upgrade all Python programs at the same time.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by qwertox on Wednesday October 05, 2022 @07:17AM (#33093904)
Thank you for bringing this approach onto my radar. It sounds very promising for solving the OS upgrade issue but also let's me finally use the latest version for my projects. I will read up on this.

Are there some recommended keywords or things to avoid which I could use to orient myself? Like "use deadsnakes" or "avoid deadsnakes"?

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @09:44PM (#33103364)
I suggest you look into Python's Poetry package manager.

There's some ways to keep multiple isolated Python environments around on the same OS (and Poetry can help with that, too). But I would suggest that you just stick every Python program in its own dedicated docker container, if you can get away with the overhead. (There are some ways to make rather slim containers.)

Of course, it doesn't have to be docker. Any other containerisation or VMs also work.

In general, I found it a good idea to keep the host operation system as small as possible, and stick everything into containers that you can upgrade separately.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by synergy20 on Tuesday October 04, 2022 @05:24PM (#33087175)
what exactly are them? I'm also back to modern c++ but I plan to only use a subset of the super set to make life easier. for example I don't need write a c++ library so many of the new (meta-template-programming) feature I don't need to pay attention to at least for now.

what I really need are RAII, smart pointer, the STL library and algorithms basically, plus simple OOP use cases, those combined are not very complicated to me.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by intelVISA on Tuesday October 04, 2022 @07:15PM (#33088467)
> what I really need are RAII, smart pointer, the STL library and algorithms basically, plus simple OOP use cases, those combined are not very complicated to me.

That's just about what anyone needs, I fear most people are simply too deep in their cargo cults these days to reason about a complex lang appropriately.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by gpderetta on Wednesday October 05, 2022 @04:40AM (#33092870)
Exactly. In fact these days you need less metaprogramming, not more.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by pjmlp on Wednesday October 05, 2022 @06:09AM (#33093426)
Agreed, I like to watch metaprogramming talks in a similar vein like solving chess match puzzles, but I hardly use any of that in my own C++ code, and tend to stay away from clever libraries.

Best part of latest improvements is that most common mortals don't have to deal with SFINAE, enable_if or tag dispatching.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by TremendousJudge on Tuesday October 04, 2022 @04:08PM (#33086002)
Similar story here. I'm constantly wrestling with the tool more than the actual problem I should be solving
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by lloydatkinson on Wednesday October 05, 2022 @05:29AM (#33093153)
All of these sorts of reasons are why I skipped learning C++ and don’t intend to use it. I learned C and then C#. I can’t imagine using C++ after using C# - modern C# and .NET have loads of performance and native related functionality including pointers, Span, AOT, etc.

From my outside perspective it seems absolutely chaotic and simply unmaintainable.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by pjmlp on Wednesday October 05, 2022 @06:12AM (#33093446)
Kind of, except for the small detail that WinDev loves their C++, and leaves to the .NET community the burden to create libraries, or even Windows Runtime components for their APIs, and also has Windows integrations that don't allow for COM implementations in .NET, forcing some of us to keep our C++ skills up to date.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eloff on Tuesday October 04, 2022 @05:29PM (#33087251)
I've always thought of C++ as the most complex programming language I know. With each revision it becomes more complex. I gave up and just moved on to Rust a year and a half ago. I have no regrets.

C++ has not quite joined Perl, PHP, and Java as languages I will not work with anymore, but it's the next logical candidate.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tasubotadas on Tuesday October 04, 2022 @06:13PM (#33087803)
No idea why you decided to lump Java together with these abonimations.

Java by itself is an extremely simple language.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tonyarkles on Tuesday October 04, 2022 @07:44PM (#33088803)
For me, one of the biggest problems with Java is its simplicity. Because of the lack of "power tools", you end up with things like dynamically assemble class instances using either XML or magic (see Spring), and adding functions at compile time (see Lombok). The last time I worked on a Java project, it was practically impossible to predict how the system would actually behave at run-time; my joke was that a lot of these tools took issues that could have been detected at compile-time and instead converted them into run-time errors.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by renewedrebecca on Tuesday October 04, 2022 @09:32PM (#33089907)
I've worked just about every day with Java for the past 22 years, and you've hit the nail on the head with the problems.

I really prefer environments where you could start with main() and figure out the behavior from there, and things like Spring make that impossible.

Really, if java only had lambdas and lisp-y macros from the beginning, we wouldn't have these problems.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by bheadmaster on Wednesday October 05, 2022 @04:11AM (#33092672)
> I really prefer environments where you could start with main() and figure out the behavior from there

This is one property of Go that I really like. Because of lack of constructors/destructors/magic functions and all that jazz, the only functions executed in a Go program are functions explicitly called through main().

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by noisem4ker on Wednesday October 05, 2022 @01:19PM (#33098418)
Watch out for init() [1]. Apart from that, however, I agree about the general lack of magic in Go.

[1] https://go.dev/ref/spec#Package_initialization

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by moring on Wednesday October 05, 2022 @04:15AM (#33092694)
IMHO, in retrospect, runtime access to annotations was a mistake. Possibly the level of reflection it offers, too. These two make all that code possible that cannot be understood statically.

And yes, lambdas and macros would probably have been a good replacement for that those two were originally meant to achieve.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by jcelerier on Wednesday October 05, 2022 @09:30AM (#33095320)
It made a ton of software possible that wouldn't even exist otherwise. We don't have runtime access to annotations in c++ and it's a constant PITA as soon as someone wants to make something as basic as generating a GUI automatically from a data model, which is maybe 50% of what programmers do all day in the world
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by moring on Thursday October 06, 2022 @02:04AM (#33104910)
I first wanted to write: Generating a GUI can happen as a fully automated build stepü, without runtime reflection.

But then I realized that such build steps re-introduce the same problems as runtime reflection does: You cannot understand the code statically.

So, yeah, maybe reflection and annotations are simply an overused hammer that makes everything look like nails... It feels like every library goes out of its way to use annotations for everything, completely defeating type-safety and static analysis. When it should actually be like, "is there really no way we can solve this without annotations and reflection".

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by jcelerier on Thursday October 06, 2022 @08:38AM (#33107487)
Note that what I'm talking about is perfectly doable without any runtime reflection at all, only through static compile-time reflection. E.g. attributes in c++ are a purely compile-time thing - if there was an API to do stuff with them it would also be a compile-time one. The code isn't meaningfully different though.

But yeah, "fully automated build step" generally looks like "let's parse enough of the language so that we can implement our own custom reflection system" which leads to every project having an incompatible one and in practice much more pain (and macros) for the developers than if it was a standard one, e.g. Qt, Unreal Engine and so many others have their custom homegrown reflection scheme and there are a thousand libs on GitHub trying to reimplement it: https://github.com/topics/reflection?l=c%2B%2B

It's exactly like type systems being Turing complete : if yours isn't, someone somewhere will be making a language that compiles down to yours with one because of how useful of a property it can be in some cases

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tasubotadas on Wednesday October 05, 2022 @04:25AM (#33092752)
I am sorry to hear that you have experienced such a sorry bunch of code-bases and frameworks but that doesn't define the language or even an ecosystem.

I've seen worse magic crap happening with Ruby and Python with their auto-magic method invocations.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tonyarkles on Wednesday October 05, 2022 @10:34AM (#33096086)
> but that doesn't define the language or even an ecosystem

I want to agree, but at least locally (as in geographically), these technologies seem to be heralded as fantastic. Maybe there's some kind of Spring Bubble around here, but on the main Maven site, Lombok shows up as the #16 most popular package (with primarily logging and language packages above it), and Spring isn't too far behind.

> Ruby and Python with their auto-magic method invocations

It's probably worth separating those two... as far as the functionality goes, Ruby and Python both have the capability of similar magic, but in my experience with popular frameworks, Ruby takes it to a whole other level while in Python it's generally discouraged.

I realize it's all anecdata here, but in my experience working with various companies and platforms, the Ruby magic generally just lives behind the scenes and Just Works. The Java magic would often turn into runtime exceptions, and the people who tried to do Ruby-like magic in Python would have similar difficulties. All of that revolved, primarily, around the ecosystems around the languages.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eloff on Tuesday October 04, 2022 @06:30PM (#33088006)
In theory Java is not so bad. I just have never enjoyed working with it or with the code Java developers end up creating. Kotlin is reasonably pleasant. I've sometimes used it when the JVM was a hard requirement.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by marginalia_nu on Tuesday October 04, 2022 @06:35PM (#33088061)
Java is like one of those ice berg memes with a lot of byzantine JVM shit lurking at the depths.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by bugfix-66 on Tuesday October 04, 2022 @06:17PM (#33087844)
I used C++ full-time for more than a decade before finally abandoning it in disgust.

Now I use Go for most purposes, and C or CUDA when appropriate.

Good riddance.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by spoiler on Tuesday October 04, 2022 @05:57PM (#33087624)
I've not worked with PHP for over 8 years now, but I hear it's gotten much better recently.

It still has issues that are commonly associated with hosting provider configuration/control over the runtime, apparently.

(sources are anecdotal; two friends who've had the mental fortitude to stick with the language for so long)

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by jmt_ on Tuesday October 04, 2022 @06:27PM (#33087968)
PHP 7 & 8 introduce lots of improvements. I used PHP 5 when I got into web dev and remember moving to Python as soon as I could. At work I've had to use PHP 7 and have been very pleasantly surprised at how solid it is. Now that I have more experience than my PHP 5 days, it's become apparent that PHP is very clearly suited for web work and the built-in functions offer many conveniences for such work that simply aren't available in other languages (granted other languages weren't built for web like PHP was). I've been surprised by my speed in PHP and I chalk most of that up to many helpful standard library functions. Even though PHP has a lot of old/compat functions still present I'm always surprised by how little that actually ends up effecting my productivity. So it's not my choice for greenfield projects but I'm not nearly as adverse to it now after working with modern day PHP for a bit.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by jamesfinlayson on Tuesday October 04, 2022 @07:04PM (#33088356)
Agreed - I've worked on a few PHP 5 era projects with hand-rolled frameworks and more recently I've worked on a few PHP 7/PHP 8 projects using proper frameworks and it's night and day.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by thrown_22 on Tuesday October 04, 2022 @07:04PM (#33088364)
This is what annoys me when people say C/C++. C++ is a mess that no one could ever learn. C is a happy little language that lets you move memory around in anything from a micro-controller to a GPU cluster. C is not getting replaced by Rust because Rust can't fit in most of the places C lives. C++ on the other hand can't die fast enough.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tialaramex on Tuesday October 04, 2022 @08:46PM (#33089455)
Don't overestimate how big Rust needs to be, for a lot of specialist micro controllers the inertia is with C because the vendor ships a C SDK. But those SDKs are often garbage, which means if one or two enthusiasts make a good Rust SDK for your preferred controller suddenly Rust has the upper hand.

For really tiny stuff Rust won't go there. If you program an 8051 clone, Rust isn't interested in your problem, ideas like "generic programming" and "pattern matching" don't make a whole lot of sense when only 128 bytes of RAM is accessible. But is C really the right tool for that environment either ?

Once you've got 64kB of RAM, that's definitely potential Rust territory.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by dkackman11 on Tuesday October 04, 2022 @04:15PM (#33086099)
Agree. Modern C++, and discussions around it, become more esoteric with every revision. As software engineers we should spend our time understanding the esoterica of the problem domain, not the toolset.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by thrwyoilarticle on Tuesday October 04, 2022 @07:25PM (#33088584)
I think this is more of a meme than reality. In the past, C++ needed manual memory management and writing ctors over and over with myriad footguns. Now someone can contribute to a C++ codebase barely knowing what a heap or reference is and the compiler will create decent code.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by hdjjhhvvhga on Tuesday October 04, 2022 @05:17PM (#33087057)
I'm of the same opinion. Frankly, when Go first appeared, I felt we would finally get something almost as simple as Python and almost as fast as C. Unfortunately not everything was as nice as I had expected. Still, in that respect it's better than Rust as it makes it easier to focus on the problem rather than the language.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by _wldu on Tuesday October 04, 2022 @05:21PM (#33087119)
The complexity of C++0x is one reason Go was created.

"For me, the reason I was enthusiastic about Go was just about the same time we were starting on Go, I read (or tried to read) the C++0x proposed standard. And that was the convincer for me." - Ken Thompson

17:45 mark here: https://www.youtube.com/watch?v=sln-gJaURzk

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tialaramex on Tuesday October 04, 2022 @07:23PM (#33088562)
For reference of anybody too young to remember: C++0x is what you'd have called what became C++ 11 back when the committee thought it might happen in 2009 or, worst case 2010.

The fact that their "2009" standard shipped only in 2011, after ripping out features everybody agreed were good yet never seemed finished, is why they moved to their current "train" model where there's a new C++ every three years, like it or not. The train will leave, if your feature wasn't ready well there's another train in three years.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by pkolaczk on Wednesday October 05, 2022 @01:19AM (#33091574)
> Still, in that respect it's better than Rust as it makes it easier to focus on the problem rather than the language.

Quite the opposite. In Go/Java I find myself frequently thinking how to adapt my problem so it can be expressed in a very limited set of language features. I want to build a house but I only get a hammer and some nails. Works nice if I want a wooden house but not so much if I want to use bricks and concrete. In Rust I get a giant toolbox with almost everything and I just pick the right tool for the job. So although I had to learn more tools initially, later I can focus more on the job, not the language, because the language adapts to the problem. And the final result is typically also better in terms of quality, performance, etc.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by bheadmaster on Wednesday October 05, 2022 @04:14AM (#33092688)
> Frankly, when Go first appeared, I felt we would finally get something almost as simple as Python and almost as fast as C. Unfortunately not everything was as nice as I had expected.

Would you care to elaborate what exactly is not as nice as you had expected? I'm really into Go and to me it really does seem as good as expected. Just curious about what made it suck for your usecase.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @04:55AM (#33092964)
Go's design always struck me as really hypocritical. At least it's initial design.

Go's designers get to use tuple for their favourite use case: returning from a function.

You as a user of the language don't get to use tuples for anything else.

(And using tuples to indicate failure is really, really silly. You'd want algebraic datatypes for that. Ie a beefed up enum, not an ad-hoc struct.)

Go's designers get to use generic functions and datastructures for their favourite use cases. Eg the infamous `make` is sort-of generic, and Go's arrays, maps and channels etc are generic.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by bheadmaster on Wednesday October 05, 2022 @09:16AM (#33095165)
> Go's designers get to use tuple for their favourite use case: returning from a function.

I wouldn't call multiple return values a "tuple". I understand where you coming from, since Python multiple return values are implemented with tuples, but still that point sounds like saying that passing multiple parameters to C functions is "a tuple".

That being said, Go's "simplicity" in design is not only about interface simplicity - it's a lot about implementation simplicity. I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with. Since Go doesn't have a concept of immutable data types (except consts), tuples would effectively be just variable-typed constant-size slices, which are already implementable as arrays of empty interfaces, but have a runtime overhead...

I hope you see where I'm getting. Creating a language is complex and has a lot of tradeoffs. Then again, I see where you're coming from. I suppose it's a question of whether or not the tradeoffs (the "hypocritical design") is worth the good parts (simplicity of language, which leads to fast compile times, fast runtime, etc.). For me, personally, it is.

Thanks for the input.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @09:36PM (#33103320)
> [...] like saying that passing multiple parameters to C functions is "a tuple".

You intended this as a reductio ad absurdum, but you are entirely right. That's how it's handled in eg Haskell.

> I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with. Since Go doesn't have a concept of immutable data types (except consts), tuples would effectively be just variable-typed constant-size slices, which are already implementable as arrays of empty interfaces, but have a runtime overhead...

I'm not sure that would be a good way to implement tuples. In fact, I suspect it's probably close to the worst way to implement them?

I'd image you'd want to take the machinery you have for structs, and adjust it so that it can deal with anonymous structs with anonymous fields identified by position. (But still preserve all the static typing, instead of throwing your hands up and going with 'variable-typed'.) The runtime overhead would be more or less exactly the same as for structs.

In general, I see tuples as a syntactic sugar over structs and expect them to be compiled like that (or better) in a statically typed language; instead of representing them as some kind of weird slice.

Theoretically, you could probably even implement tuples-via-structs as a preprocessor.

> I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with.

Yes, so instead of abstaining from tuples, because of these complications, they added a special case for their favourite use case.

Have a look at OCaml for a relatively simple language with less design hypocrisy, and fast compile times and fast runtimes. (Compared eg to the much more complex Haskell.)

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by hdjjhhvvhga on Wednesday October 05, 2022 @11:27AM (#33096802)
> Since Go doesn't have a concept of immutable data types (except consts)

I believe this is incorrect. Strings are immutable, for example. You could also say the same about pointers and maybe a few other data types.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by bheadmaster on Wednesday October 05, 2022 @01:03PM (#33098195)
You are right.

Now that I've had more time to think about it, I think the problem of Python-like tuples in Go is that they require Pythonesque everything-is-a-reference paradigm in order to function the same way, otherwise they just act as heterogenous arrays in Go (which exist as arrays of empty interfaces, with a slight runtime cost). Go is mainly value-oriented language like C, with the exception of built-in container types and strings (and maybe a few others that slipped my mind).

I suppose that adding fixed-type pass-by-value tuples would essencially be reimplementing struct. Go doesn't like duplicating functionality.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @09:36PM (#33103325)
See my other comment: tuples should be thought of as syntactic sugar over structs, not arrays.

Whether to pass by reference or value and other design decisions should probably be taken (as much as practicable) from the design decisions for structs in your language.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by stark98 on Wednesday October 05, 2022 @12:06AM (#33091101)
> Unfortunately not everything was as nice as I had expected.

Could you elaborate? I'm considering switching to Go for the same exact reasons you listed.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by hdjjhhvvhga on Wednesday October 05, 2022 @08:31AM (#33094594)
I should have clarified I was one of early adopters and my main gripe then was mainly about its performance, not the syntax. I mean it was okay, but still not up to my expectations. But that was over a decade ago! Next time when I have the luxury of choosing the language for a new project I'll definitely take Go into consideration. It has its quirks but overall it's quite simple and manageable - you can easily understand code written by someone else which is a huge advantage.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by xyzzy4747 on Tuesday October 04, 2022 @05:51PM (#33087549)
I personally still don't understand the benefit of Go vs Java? They seem to accomplish similar things with similar amounts of boilerplate.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by tomohawk on Tuesday October 04, 2022 @05:58PM (#33087636)
Having used both professionally (several years each), Go is massively simpler than Java, at least for the problems we tackle. We sometimes will get a new dev on the team from Javaland, and the biggest thing for them is unlearning all of unnecessary complexity. YMMV.
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.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by hellcow on Tuesday October 04, 2022 @04:13PM (#33086073)
> I am trying very hard to imagine any other higher level language where two distinct language features, each used correctly in their own way, can not be safely combined.

Handling JavaScript exceptions as opposed to promise rejections in async code is a continual source of pain. They don’t work together. If you do try/catch on async code but forget to call await, catch will never be hit and your program might crash. There appears to be no linter available to detect this. Unless I’ve completely missed something, the interaction between these two features is a terrible design.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by masklinn on Tuesday October 04, 2022 @03:12PM (#33085268)
> I am trying very hard to imagine any other higher level language where two distinct features, each used correctly in their own way, can not be safely combined. The only thing that comes to mind are python's default parameters and passing an empty list as one.

And even then it's not a bug per-se, at best a misfeature (it can be useful as a performance hack although the performance improvements of global and builtins lookups of 3.11 might finally put that to rest).

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by avgcorrection on Tuesday October 04, 2022 @03:15PM (#33085315)
There are two sorts of languages: languages with a coherent feature set and those that people actually use. Wait hold on, that doesn’t apply here…
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by 0xbadcafebee on Tuesday October 04, 2022 @03:47PM (#33085726)
I find it unreasonable that every language would have all of its features always compatible. Why can't we just say "don't use X and Y together" ? It might solve a ton of problems. All you have to do is have a big red warning in the manual that says DON'T COMBINE X AND Y, and a language feature that lets you turn on X and turn off Y.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by j-krieger on Tuesday October 04, 2022 @04:15PM (#33086104)
> Why can't we just say "don't use X and Y together"?

Because that goes against the most fundamental idea of programming languages that you can build larger abstractions by combining basic building blocks.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by travisgriggs on Tuesday October 04, 2022 @04:40PM (#33086471)
Abstractly speaking, what if we consider a "big ball of spaghetti" and "working program" to both be abstractions of just "a program". Now it fits under the larger abstraction umbrella still. :D

All other things aside, C++ seems to be the language "to big to fail" and so it just keeps getting more and more features added to keep it competitive.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by lionkor on Wednesday October 05, 2022 @04:30AM (#33092791)
Its okay to say "but you cant combine those two". Its also okay to point out that not every feature should be combinable with every other feature, and that needing to do so is likely an indicator of terrible (user-side) software design
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @04:58AM (#33092982)
Then at least the compiler should complain, when you try to combine incompatible features.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by 0xbadcafebee on Tuesday October 04, 2022 @05:16PM (#33087035)
A half dozen languages already do this and abstractions still work
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by CJefferson on Tuesday October 04, 2022 @04:45PM (#33086545)
Who reads the "manual of C++" -- what even is that, the standard document (certainly no-one should read that for learning).

It would be just about OK for the compiler to refuse to compile X and Y together.

If you "switched off" X, then in C++ (where code is in headers which are just concatenated with your code), this would effectively split the language, as you also couldn't use libraries which use X in their headers.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by extropy on Tuesday October 04, 2022 @04:31PM (#33086361)
Sure, here is your Lego set. But do not put while bricks next to red ones or it will explode!
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by jejones3141 on Tuesday October 04, 2022 @05:01PM (#33086815)
Orthogonality has been recognized as desirable at least since the days of Algol 68. Once you couldn't pass a struct as a parameter in C. Now you can.