Friday, December 4, 2015

Swift got it closer, but still fails

Continuing my religious and long war against null beings.

I just read about Swift improvements to avoid null pointers. In Swift a variable can not be assigned a null (nil in Swift nomenclature) unless it's declared optional. And this nil is actually an object of a defined type with a presence in memory, not a pointer to a forbidden memory address (0 in practice).

Still, while Apple's guys got closer to a solution, they didn't get the point.While the solution proposed by Swift fixed the Null pointer exception, it doesn't fix all the semantic inconsistencies of using Nulls. A nil object in Swift is still something empty of information, and so the "information lost" is still present.

The solution to fix the problem was much, much simpler and much, much more effective:

- DO NOT ALLOW NULL VALUES IN THE LANGUAGE.
- FORCE THE DEVELOPER TO USE SENSIBLE DEFAULT VALUES OR RAISE AND EXCEPTION IF THAT'S NOT POSSIBLE!!!

See more about it http://chuletario.blogspot.com.es/2011/05/kill-null-killen-all.html).

No comments: