My hot take is that C++ should never have shipped lambdas without a borrow checker
Lambdas without memory safety is just a misrepresentation of what your language can do
@rain i used to work at a place that used lambdas really heavily in an async C++ codebase that also did FFI with javascript and shared pointers between the two. they had segfaults in prod nearly every week lol
@jyn @rain that sounds like actual hell
@iximeow @rain it was also the first codebase i ever worked on full-time in a professional capacity 🙃 my boss couldn't understand why i hated it lmao

@iximeow @jyn @rain yeah you can write the equivalent of async rust in c++ with no borrow checker. it is so dubious that there's a clang tidy lint just telling you to not capture *anything* in an async lambda *ever* because the *lambda object itself* can and often will vanish before the end of its own execution due to the surrounding function returning.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rcoro-capture

it's simply absurd.

C++ Core Guidelines

The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++

@iximeow @jyn @rain i learned about this excellent footgun that makes async c++ worthy of jokes because of enabling this lint on lix which *does* use async c++ (as a replacement for setcontext based coroutines, which are worse). it did catch a bug.

now if you ever do that you have to tell your fellow maintainers and the linter why it's ok.

temporary objects' lifetimes are such a funny footgun. and by funny i mean a billion dollar mistake.

@iximeow @jyn @rain our linter is shaping up to be extremely mean to you, and we're going to ship a lot of runtime checking in production if it doesn't have perf impact (we shipped checked signed integers already, no impact). there's not very much else that *can* be done tbh, c++ just doesn't have tools to write safe code.

and the bugs I've caught due to asan have been ridiculous shit like "oh a uaf is happening due to string_view from a string that's modified later in the same function". sigh.