cr212
asset1 = await httpGET(...)
asset2 = await httpGET(...)
from: assets = await Promise.join(httpGET(...), httpGET(...))
asset1 = assets[0]
asset2 = assets[1]
Where the first does one request and doesn't start the next until the previous had completed, and the second does them concurrently.BUT - you could have a language where async functions are awaited by default, and you'd have to write something like:
assets = Promise.join([pending httpGET(...), pending httpGET(...)])
Where pending means don't await, and absence of it when invoking an async function does require it.Presence of an 'async' decorator on functions isn't strictly needed, but does convey extra information in the API, which is useful.
i) There's RuntimeException which is an unchecked exception which could happen anywhere, so even the absence of a throws is not a guarantee of not throwing.
ii) In order to avoid many different throws specifiers, you end up with wrapping exceptions to a smaller set of exceptions (e.g. JNDI may throw a NamingException that wraps an IOException)
iii) IDEs offer to put try-catch { // todo } to avoid compiler errors. Developers often stop thinking then, where the right thing is more often to let it throw - e.g. I've seen FileNotFound being caught and logged (at debug) and not exposed to a caller, so a UI doesn't see it, with bad results.