3 ms·
Personally, my issues with threads and the various locks is that you have to manually manage resource ownership. It's kind of like programming without types, wi
by rovolo 7y ago
Personally, my issues with threads and the various locks is that you have to manually manage resource ownership. It's kind of like programming without types, with manual memory management, or with null values. It's easy to program with 'null' if you do it every day, but it wears on you and there's always the chance that you make a dumb mistake. Moving that functionality into the type system is a relief because you can lean on the compiler to tell you when you're doing it wrong.
I like promises/futures because they tell me when resources will take a while to become available without blocking. I generally don't want to need to know that I need to lock the foo queue before consuming from the queue. I would rather have the queue handle that for me and encode the behavior I want in the type signature:
next() -> T sync, blocking
poll() -> Optional<T> sync, non-blocking
next() -> Future<T> async