3 ms·
This line of thinking led me to think: global variables should be, rather, considered good! Plain text is the problem. We write code so it can be easily read a
by valty 3y ago
This line of thinking led me to think: global variables should be, rather, considered good!
Plain text is the problem. We write code so it can be easily read as plain text. Not as living, breathing, running code.
Globals are considered bad because they are hard to trace and reason about. But this is only so with plain text. You cannot click on a variable and see all it's dependencies. We must painstakingly trace these.
If we visualized the dependencies and the flow of our code, we could see the complexity as we go. And the "context" becomes automatic. There is no difference between explicit and implicit context.
The key for globals, is to have one large graph data structure where everything is related. All your data is modeled the same. No mini-databases spread out over the code. No ad-hoc indexes strewn throughout. No modularity. One single giant data model.
- akkartik 3y agoI'm very sympathetic to this idea. The challenge becomes the UX and accessibility of browsing this one single giant data model. I like global variables as well. One awesome thing they enable is custom debug UIs: http://akkartik.name/post/2023-10-31-devlog http://akkartik.name/post/2023-10-31-devlog http://akkartik.name/post/2023-11-04-devlog http://akkartik.name/post/2023-11-04-devlog