|
|
|
|
|
by Neywiny
397 days ago
|
|
I don't get it. The first example in JS vs Java looks very similar. Now all those other code blocks, they certainly have more going on but idk how that compares to JS. And to answer the questions: A completable future is something that in the future may complete. I think that's self explanatory. A promise seems equally vague. Boilerplate looks the same. JS is just a function, Java they put a class around it. Java requires exception handling which is annoying but having fought errors in async JS, I'll take all I can get. API is eh. Sure. But that's not even shown in this example so I have no idea. So JS saves like 3 lines? Is that really so much better? |
|
I don't use Java async much, but I guess if you have a utility method named "setTimeout" than the example can simply be:
Which is simpler or equivalent to the JS example.