On 4/18/2016 8:24 PM, Stanislav Malyshev wrote:
>> to have them calls them a "billion dollar mistake", many languages
>> actively avoid having NULL in favor of something deliberately more
>> structured.  NULLs are a very common cause of avoidable fatal errors in
>> many languages (including PHP). NULLs are rude to users of your API, as
>> it balloons the error handling code they need to deal with.
> 
> I think this description is misleading in a way. Nulls are immediate
> causes of many errors, technically, in a meaning that "if I find null
> where I expected to have DB connection, I get an error" - but this is
> only a technical cause. The *real* cause is the failure to check whether
> your attempt to connect to the database succeeded, or that you have
> proper DB configuration, or such, and null is just a symptom of that
> error - and that error is not automagically fixed by having some other
> object instead of null. You have to actually design and write code for
> it, there's no replacement for it.
> 
> So declaring null "cause of all evils" is ignoring the real causes and
> blaming immediate technical cause instead, and it would not be helpful.
> It is true that for some languages with more complex type systems it is
> possible to largely get rid of nulls by using those complex types and
> ensure type system controls for all checks at least to be present (note
> that doesn't guarantee proper function either, since no type system can
> ensure you handle the case of missing DB connection properly, it just
> can ensure you have a branch for it). But that requires much more
> complex and involved type system that PHP has - or, in my opinion,
> should have.
> 

I agree with Stanislav here. *NULL* is not evil per se and just because
some functional languages get some attention right now does not mean
that they solved the biggest mistake in CS history. On the contrary,
they just invented another way of handling it by introducing new types
that require more book keeping and by refusing to compile if they
encounter a place where proper handling is missing.

As I wrote earlier, we could introduce such a feature into the language.
However, static code analyzers can already provide this functionality.
People just need to use them.

TL;DR *NULL* is just fine if used correctly and we cannot make sure that
people use it correctly.

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to