Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That is a feature of unconstrained, shared, mutable state. While singletons are often used that way, there are two problems with the resulting code. On the other hand, imagine a hypothetical situation where you have a bunch of static data that you would prefer is only generated once, and only ever generated if needed. A singleton gets this done, without any sort of "where on earth is this set to X?" but retains issues with injection for testing and the like (depending on precisely how it's implemented, in most languages).


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: