3 ms·
You would normally check null on language boundaries: val path: String = req.pathInfo ?: "" Now path is a non-nullable String, and you can be sure that it w
by nostrademons 10y ago
You would normally check null on language boundaries:
val path: String = req.pathInfo ?: ""
Now path is a non-nullable String, and you can be sure that it will never contain null, and you have specified exactly what the behavior is if the Java API returned it.
> Yeah, that's pretty terrifying. I would never want to use a language that expected me to make extensive use of a C FFI. It was bad enough when I used Python, and that involved a lot less C than Kotlin does Java.
You do this every day, regardless of which language you use. Your POSIX APIs and OS services are all in C. That they generally work is because numerous people have invested the time into putting appropriate error checks & memory safety into the host language bindings.
It's the same story with Kotlin: when you write code that uses a language (Java) that doesn't have appropriate safety mechanisms, you read the docs & code carefully, and then you use the safety mechanisms that your language (Kotlin) gives you for all the code you write. There is really nothing Kotlin can do about this: the original code is written in a language that doesn't make the distinction between nullable and non-nullable, so there is no information in the type system about whether it should map to a nullable or non-nullable type.
- lmm 10y ago> You do this every day, regardless of which language you use. Your POSIX APIs and OS services are all in C. That they generally work is because numerous people have invested the time into putting appropriate error checks & memory safety into the host language bindings. Not when I'm working on ocaml unikernels, but sure. The point is I only use languages where those bindings already exist and are maintained; I wouldn't want to use a language that expected me to use a C FFI directly in day-to-day work. Whereas the Kotlin narrative is that you do use the Java "FFI" directly in day-to-day work.