Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Every time I read an article like this I thank the day when I switched from C++ to go. I know why C++ is like this, I understand all the hard work that went into evolving it over 40 years, but I simply refuse to deal with all this stuff anymore. I have better things to worry about in my life.


Yeah... I used C++ coroutines a bit and they're super powerful and can do anything you want... But... I mean look at how complex co_await is:

https://en.cppreference.com/w/cpp/language/coroutines.html#c...

It does about 20 different steps with a ton of opportunities for overloading and type conversion. Insanely complicated!

And they kept up the pattern of throwing UB everywhere:

> Falling off the end of the coroutine is equivalent to co_return;, except that the behavior is undefined if no declarations of return_void can be found in the scope of Promise.

Why?? Clearly they have learnt nothing from decades of C++ bugs.

Hopefully Rust gets coroutines soon...


> I mean look at how complex co_await is

it doesn't look meaningfully more complex than C#'s spec (which has absolutely horrendous stuff like :throw-up-emoji: inheriting from some weird vendor type like "System.Runtime.CompilerServices.INotifyCompletion")?

https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...


Out of curiosity, what would you use coroutines for, in Rust?

My personal use was clearly `async`/`await`, and this landed quite some time ago.


For stimulus generation for SystemVerilog tests. I think you might be able to use `async`/`await` for that but I'm not 100% sure - I haven't tried.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: