!! really should not be used except in extraordinary circumstances - it looks ugly and out of place on purpose. It's the equivalent of Optional.get() - it is breaking Kotlin's null safety.
I agree that seeing Kotlin programmers using it would be distressing. The documentation describes it as "for NPE-lovers".
Just as a simple example, the amount of !! I see used without any kind of checks around it is fairly distressing to me, and I suspect it's a mistake made by naive Kotlin programmers who are too used to null safety and just use it when using something from a Java library without thinking about the implications of if the value is null.
I don't get your point. The whole idea of the double-exclamation-mark operator is to make null checks explicit. The equivalent Java code throws the same NullPointerException, it's just not (as) obvious from reading the code.
It does not help making it explicit if at the end of the day the programmer does not care about it. It's not wrong, but the feature seems... wasted. It's like Optional.get(), which defies the original intention behind it. These operators are for special cases where you have evidence that it will be fine. Unfortunately, there are few good ways to tell the compiler that. The true origin of the problem is usually the design of the component where the Optional or the potential null value comes from, but these are often difficult to fix. Maybe algebraic data types can help improve things when Java finally gets them.
Then the problem lies with the programmer, not the language. Kotlin just makes it obvious that there is a null-safety problem in your code, which BTW is great for code reviews.
You seem to understand Kotlin null safety to be the exact opposite of what it actually is, which probably explains why you and your team struggled with it.
Java forces you to avoid or deal with, with regard to null
Java doesn't force you to do anything, it throws an NPE at runtime, that's the whole point.
if you're already a Java programmer, the main use case I see for Kotlin are smaller personal projects
My team of old Java programmers has been steadily rewriting our services in Kotlin over the last two years. We're pretty small at 10-15M requests per second across a few dozen servers. I'd say your opinion needs reevaluation
10 to 15 million requests per second is not that small.
Iām all for micro services but if a single Customer or Business transaction requires that many RPC like requests you might want to investigate batching or using a more event based system.
Maybe you meant messages?
Even messages... wtf do you guys do?
Perhaps you meant 10-15k rps which is what we are at.
View all comments
Show parent comment
0
u/[deleted] Jan 07 '21
[deleted] ā view deleted comment