4 ms·
A little more verbose? Lets see, Scala vs Java in a promise-based async server: Java (real code - this is a mild example, imagine this 8 indents deep): retu
by jaen 14y ago
A little more verbose? Lets see, Scala vs Java in a promise-based async server:
Java (real code - this is a mild example, imagine this 8 indents deep):
return users.verifyAccess(userId, oldPassword).flatMap(
new Callable1<Promise<DataObject>, UserProfile>() {
@Override
public Promise<DataObject> call(UserProfile profile) {
return replyProfile(profile.setPassword(newPassword));
}
});
Scala (translated):
for {
profile <- users.verifyAccess(userId, oldPassword)
} replyProfile(profile.setPassword(newPassword))
(observe how you can actually read the code)
Oh man, I wish we started with Scala (or wrote everything sync)... My conclusion from all of this was that Java makes certain abstractions impractical from a readability standpoint.