Hacker News new | past | comments | ask | show | jobs | submit login

The worst thing - default values as a solution for absent values. What can go wrong with implicit value assignments?!





Would you rather have undefined initial values?

I would. Not because it's something pleasant.

There is a huge difference between no value and default value. I had plenty cases where I needed to distinguish them because absent value is a violation of a contract. Defaults are not a solution.

And more. Defaults bring their own problem. Chosen values are neutral only for some operations. The most simplest case - int default value is 0, but it kinda "works" only for sums. With nulls you'll get an error in production. With defaults discovery of the error is postponed even more. It's literally the same as making up values ignoring clients will (and this decision even not ours but designers of the lang).

Defaults are implicit. It's simplifies mistakes due to human factor.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: