5 ms·
I should have been more specific. Yes, the --strictNullChecks switch almost gets you there.. I forget there's also the 'never' type, and '{}', which are very si
by velox_io 8y ago
I should have been more specific. Yes, the --strictNullChecks switch almost gets you there.. I forget there's also the 'never' type, and '{}', which are very similar to null (I've seen someone use the string null in production).
The reason I bring this up is that if you remove null, it removes the need for both of '==' & '===' (could possibly be removed with something like strictEqualityChecks).
Exception handling and null checks are both conditional, so there is the potential to replace checking for null with exceptions. Plus, removing the null checks (is an object still an object when most of its properties are null?) could be fixed with better use of inheritance. And the '?' suffix.
This is not the first language Anders has been involved in developing, I'm sure remember him talking about his dislike for null somewhere (I could be wrong). Typescript is both an abstraction and adds features to Javascript. So TypeScript has the opportunity to remove such idioms. Scala and Java are very different languages despite running the same underneath.
The question at the end of the post was more hypothetical. Could this be done or is the concept of null is so ingrained that it can't be removed? (When Functional programming manages null.) I'm just interested, especially when null is known as the "Billion Dollar Mistake" - that's ignoring inflation.