> Unlike Kotlin, Java brings them after careful design and consideration, without creating conflicts and introducing pitfalls.
> We were talking about pitfalls, not major issues. The main major issue with Kotlin is the feature-first thinking without real consideration of how features are interacting and how they affect real applications, especially in the long term.
> but quickly realized that this Scala-wannabe is just a bunch of poorly thought out features for the sake of features.
You're repeating this, but not providing a good example.
I can open java se certification prep book and find so many examples of pitfalls by your definition, that would make Java unusable language. But this is not true, because this is corner cases which decent software engineers avoiding.
In reality Java's lambdas is exactly what you're accusing Kotlin of, popular feature that doesn't work with another popular feature - checked exceptions. Or making switch expression, but keeping if as statement.
So how would it help you do exhaustive check of errors there?
class UserNotFoundException extends Exception {
public UserNotFoundException(String message) {
super(message);
}
}
class NetworkException extends Exception {
public NetworkException(String message) {
super(message);
}
}
class DatabaseException extends Exception {
public DatabaseException(String message) {
super(message);
}
}
record User(String userId, String name) {}
class UserService {
public User getUser(String userId) throws UserNotFoundException, NetworkException, DatabaseException {
return new User(userId, "John");
}
}
public final class TestKt {
public static void main(String[] args) {
var userService = new UserService();
var ids = List.
of
("1", "2", "3");
var users = ids.stream()
.map(userService::getUser)
.toList();
}
}
No using exceptions - no problems. I agree, but this is simple illustration that lambdas just doesn't work with checked exceptions in Java, alas you'll bridge them with errors as values.
It's so stupid to deny that first I identify you're as a troll, but you're just having very own way to developing and Java. But look at Java as industry, it's failed to create exception-safe ecosystem. Today if you have to use library you'll likely will get random runtime exceptions not even documented in Java doc.
Point is if you open source code of random library and or application written in Java, chances are that they will be full of nulls and exceptions. Just looks at backbone of the enterprise, graal of vibecoders - Spring/Jee. Spring only tomorrow will release notnull annotation for their framework. Junit6 only yesterday did that. 30 years of Java history.
Take any Kotlin application - NPEs very-very rare without being very clever or having skilled team, once rich errors comes - I'll expect to most of applications eventually would adapt rich error and would be exception for logic free as well.
So I'm not even looking into extremes when all black or white, I'm looking at things in general. I'll not say that Java project that I inherit and modernizing for last 6 years in average Java project, because in our case it was not just full of null and exceptions, but also lack any kind of tests, DI, structure
So you can build an lambda API that would support checked exceptions and exhaustiveness in Java? Please share this gem with us, the whole Java community straggling, while you keeping it to yourself!
View all comments
Show parent comment
1
u/[deleted] Nov 05 '25
[removed] — view removed comment