When 'perfect' code fails

30 points by mrk


ek

The post doesn't blame Javascript's loose type-system, but I think that's also a place this could have been avoided.

In stronger typed languages, if (isOwner(...)) would be compiler error, if condition must be Bool but was type Promise<Bool>.

Sure "truthy" and "falsy" values let you save a ton of typing for "null" checks and are convenient sometimes, but this is a great example where a runtime exception or typescript compiler error would have been a way better outcome than "eh, I guess a function value is true".