4 ms·
>Java also could not fix it (which may be one of the main reasons behind Kotlin). C# added some null-safety features despite having a 20-something year baggage
by 5e92cb50239222b 5y ago
>Java also could not fix it (which may be one of the main reasons behind Kotlin).
C# added some null-safety features despite having a 20-something year baggage of legacy code. While it might not be the perfect solution (these checks work only at compile time and you can enable them per-file), I find that they work great for new projects. You have to be extra careful at boundaries (interfaces with third-party libraries which have not added ? annotations yet, API calls, and so on), but they save a lot of headache inside your own code.
- cies 5y agoCool. It's a bit like what Kotlin did. Yet after some experience with Kotlin I found it is not perfect. "You have to be extra careful at boundaries" exactly, with Kotlin too. The question mark is the best thing if you have not build your language with null safety to start with. Please look at Elm for a good example of what real null safety looks like. With Go they had to change to do the right thing from the start. I really wonder why they didnt.
- lazulicurio 5y agoAlso worth noting that Java may be able to fix it in the future after Valhalla drops (and this may mean better implementation for JVM-based languages too).
- cies 5y agoI sure hope so. Not holding my breath though. :)