Hack has introduced asynchronous programming. This is really great but it is not really documented at the moment. Not at all actually… I’ve done some experimenting and I will try to introduce you to the new concept.
There is two new keywords async and await. Async is used to declare a function as asynchronous. You need to declare the function with async if you want to run it in parallel with other functions. Every async function will return an Awaitable.
Instead of the join function you may use the await keyword to suspend the execution of the async function waiting for the WaitHandle to complete.
There is also a series of object inheriting WaitHandle which you may us. Below is an example where you stack up asynchronous calls in a GenVectorWaitHandle and execute them all at once.
Notice the last 5 lines in the output. The threads started at the very same time but completed at random order.
I think this feature need some more work before anyone should use it in production. We also need some more documentation on hacklang.org.