3 ms·
So what I personally find interesting about this code is how it just... asychronously kicks off arbitrary functions. It reads like scripting except it isn't. I
by wonderzombie 14y ago
So what I personally find interesting about this code is how it just... asychronously kicks off arbitrary functions. It reads like scripting except it isn't.
I ask out of curiosity: are there other statically typed languages where you can do stuff like this? Java has Futures, but those are far more heavyweight. Clojure has concurrency constructs which are pretty close, but Clojure is dynamic. I only know a little bit of Haskell, so there might be something like this in there.
- thebigshane 14y agoC# now has `async` and `await`, not the same thing, but similar. Also I'm sure there's about a dozen C++ libraries that will do it.
- throwaway54-762 14y agoRust (another "systems language of the future") has a lightweight syntax for spawned "tasks", I think. But I'm far from a Rust expert.
- burntsushi 14y agoThis is true. Rust also provides more compile time safety (a lot more actually), but it comes at the cost of complex semantics.