Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
grandempire
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
34 ms
·
511.
▲
by
grandempire
2y ago
I agree that dependent sequences of events, coordinated through a global are bad. But there are other usages which are not error prone. For example an allocation, logger, readonly settings, or a cache.
512.
▲
by
grandempire
2y ago
> I’d say this is mostly a function of the language or framework. frameworks cannot ensure your program does what it's supposed to. People are responsible, not tools. > contributors are humans Yes - which is why I would discourag
513.
▲
by
grandempire
2y ago
> That one person that creates threads haphazardly will wreak havoc What if someone comes along and starts adding threads and doesn't check what they are accessing? And doesn't read the documented invariants of the design? Wel
514.
▲
by
grandempire
2y ago
Because as a programmer I have responsibility for the technical soundness of the program, and I don't create threads haphazardly. > when i thought i understood multi-threaded code, but didn't. All the more reason to carefully p
515.
▲
by
grandempire
2y ago
The burden is on the programmer adding a new thread to know what they can safely access. The conclusion of your argument looks like 2000s Java - throw a mutex on every property because you never know when it will need to be accessed on a th
516.
▲
by
grandempire
2y ago
I've recently found it helpful to think of problems at the scope of an individual process, rather than a set of functions in a library or framework. This makes it much clearer when a global variable makes sense or not, and generally wh
517.
▲
by
grandempire
2y ago
Why are singletons better? That's just a global object. > wrap a mutex What if my program has one thread? Or the threads have clearly defined responsibilities?
518.
▲
by
grandempire
2y ago
strict aliasing is an example of questionable optimizations from hard to verify assumptions.
519.
▲
by
grandempire
2y ago
Certain C optimizations are difficult to implement due to pointers. But that doesn't make pointers themselves complicated. Most of the C community agrees that strict aliasing assumptions are more trouble than they are worth.