4 ms·
Java gets better with every release and is a pretty decent language today. But Kotlin feels just more consistent with less corner cases. Let me name a few thing
by cryptos 7y ago
Java gets better with every release and is a pretty decent language today. But Kotlin feels just more consistent with less corner cases. Let me name a few things:
* No checked exceptions destroying lambda expressions and leading to architecture problems (since exceptions are oft not used like the inventors of checked exceptions assumed).
* Functions are real first class citizens and don't need artificial interfaces.
* Named parameters with default arguments are very practical.
* `name: Type` is a better fit for type inference than `Type name`.
* Null-safety helps to avoid lots of bugs.
* The type system with `Any` as a unified root and `Unit` instead of the special case `void` makes programming with generics much easier.
* Constructors are always lean, not only for data classes (record in Java 14).
* Most things are expressions, so you can write `val a = if(cond) 1 else 99`.
* Extension functions and operator functions can be used to write simple to use and elegant APIs.
So at least for me Kotlin is definitive the better Java and I wouldn't start a new project with Java, if I could use Kotlin instead.
- Stratoscope 7y agoMobile-readable version of your list: * No checked exceptions destroying lambda expressions and leading to architecture problems (since exceptions are oft not used like the inventors of checked exceptions assumed). * Functions are real first class citizens and don't need artificial interfaces. * Named parameters with default arguments are very practical. * `name: Type` is a better fit for type inference than `Type name`. * Null-safety helps to avoid lots of bugs. * The type system with `Any` as a unified root and `Unit` instead of the special case `void` makes programming with generics much easier. * Constructors are always lean, not only for data classes (record in Java 14). * Most things are expressions, so you can write `val a = if(cond) 1 else 99`. * Extension functions and operator functions can be used to write simple to use and elegant APIs.