LastExceed
03/06/2020, 1:55 PMassert()
from the kotlin stdlib and assertEquals()
from junit. the former is basically implemented as
if (!condition)
throw Exception(message)
its as simple and intuitive as can be. meanwhile the implementation of the latter goes so far down the rabbit hole (I have to navigate through 4 different files for what is actually just 5 lines of code) that I'd have trouble understanding what the function even does if it wasn't for the descriptive name. And this isn't just some random snippet from a stranger on the internet, its one of the most popular testing frameworks out there.
just why??
Edit: I don't just mean to vent, I mean this as an actual question. Why is this? There's gotta be a reason for itMike
03/06/2020, 3:15 PMassert()
to assertTrue()
. assertEquals
is attempting to handle the object type correctly, so if it's a List, compare elements. if it's a Map, compare items etc.
A lot of Java examples are likely 'old', too, and still using Java 8. Java 14 has come along nicely, and supports more of what Kotlin allows.
And some of it depends on what you work with most. What we know is always more comfortable than what we don't know or use as often.
People coming from Java to Kotlin often find the use of stdlib functions confusing, and can't understand why their favourite feature from Java isn't present in Kotlin (ternary, static), rather than understanding the idiomatic way.
HTH a bit. JDK8+ really helped reduce the differences, but overall, Kotlin is definitely cleaner. If it wasn't, then JB wouldn't have bothered, as that was one major motivation for them.alex
03/31/2020, 12:48 PMMike
03/31/2020, 1:04 PMalex
03/31/2020, 1:14 PMalex
03/31/2020, 1:15 PMMike
03/31/2020, 1:31 PM