Re:Rust – How do I create a global, mutable singleton? (2015)
by aphextron on Wednesday July 22, 2020 @10:44AM
(#23917560)
It's not a simple yes/no question. For instance, is a database not ultimately a single mutable global state?
[ Parent
| on HN ]
Re:Rust – How do I create a global, mutable singleton? (2015)
by chousuke on Wednesday July 22, 2020 @11:05AM
(#23917794)
Databases are also designed for safe concurrent access with enforceable constraints on data. Would you like your application behaviour to depend on a transient "database" someone made up on the fly? :)
I think the key is that your database stores data that lives outside your application, making it observable outside any particular application instance and allowing you to perform ad-hoc queries to validate consistency and fix problems. If you have such mutable state inside a process, it can be very difficult to debug problems when a series of interactions sends your process into an inconsistent state that is only detected some hours later when (if) it finally crashes.