5 ms·
Difficult problems in programming: (1) cache invalidation (2) off-by-one errors
by segfaultbuserr 6y ago
Difficult problems in programming:
(1) cache invalidation
(2) off-by-one errors
- mattiasfestin 6y agoThe classical three problems.
- xarope 6y agoI thought the two hardest problems were: 1) naming 2) cache invalidation ... 3) off-by-one errors
- waheoo 6y agoI feel like we should have solved the naming problem as an industry by now. Alas.
- layer8 6y agoIt’s actually the hardest one of the three, being outside the grasp of formal methods.
- kreeben 6y agoTo solve this problem we would need to first understand the human mind, how it stores data, how it does computation, and how it interacts with names. So we would need the same set of information that we would need for creating AGI. A solution is probably only a couple of months/decades away.
- waheoo 6y agoI really have to disagree, why can't you devise a formal method? - a good name should be descriptive - avoid being overly clever, call a spade a spade - don't optimise for generalisation, naming things is a time to be specific - aim for short but not at the expense of losing context - avoid redundancy in naming of things nearby, leverage spatial context - avoid qualifiers or type information where possible - type should be obvious from context and use, if it's not qualify or refactor Anything else?
- layer8 6y agoThose aren’t formal definitions. “Formal” means, at the very least, that the specification is done in a formal language, and usually that conformance to the specification can be checked mechanically, that is, by a computer. https://en.m.wikipedia.org/wiki/Formal_methods https://en.m.wikipedia.org/wiki/Formal_methods
- Ancapistani 6y agoI'm pretty sure it's: 1) naming 4) concurr2) cache invalidationency ... 3) off-by-one errors
- hesdeadjim 6y agoLove this.
- deleted 6y ago[deleted]
- edgyquant 6y agoYou forgot 0) Race consegmentation fault (core dumped) (I know I was ninja’d but didn’t see until after)
- account42 6y agoFWIW, your version has the nice touch of also introducing a 0th item.
- echelon 6y agoPer your downvotes - I used to hate jokes on Hacker News and downvote them when I saw them, but I've become more ambivalent. They're a way of amicably sharing culture and experiences with other engineers that transcend any differences in age, gender, race, background, etc. The formulation of this joke I tend to see is, The two hardest problems in programming: (1) cache invalidation (2) appropriately naming things (3) off-by-one errors
- Twisol 6y agoIt's barely even a joke to me anymore -- it's just too real for me to laugh. (Cache invalidation is essentially the same problem as managing mutable state -- "Out of the Tar Pit" frames mutable state as either essential or incidental, the latter being rederivable in principle from essential state. Incidental mutable state is no more and no less than a cache, and usually one with an informal and undocumented invalidation policy.) (And naming things has a very real technical counterpart in addressing, which comes up obviously in networking, but you can also see its shadows in quite a lot of concerns around architecture and modularity.)
- imoverclocked 6y agoHumor is often the most efficient way to communicate/accept the truth.
- pablius 6y agoTo make the truth seem like an acceptable parallel universe, and then join it.
- JBiserkov 6y agoThe two hardest problems in programming: (1) cache invalidation (3) off-by-one errors (2) appropriately naming things (4) parallel execution [leading to race conditions / ordering bugs]
- lifeisstillgood 6y ago
- bouncycastle 6y agoshouldn't your list start from 0?
- eru 6y agoFortunately, many off-by-one errors can be caught with more ergonomic tooling. For the simplest example: compare the old C-style for loop vs a Python style for-each loop.
- Gene_Parmesan 6y agoI don't find I ever make off-by-one errors with simple collection iteration; at some point "i < len" becomes tattooed on your brain stem. The off-by-one errors I tend to make are related to implementation details of certain data structures or algs. Really, I would describe them more as "thinking at the margins can be challenging." Correctly handling doubly linked lists, that sort of thing. Oh, and slicing. I will never get Python slicing right the first time. The fact that the range is [begin, end) is just never the way I expect it to work.
- Ygg2 6y agoBut slicing 0..len and for (i=0; i< len) are literally the same thing. In [0, len) ')' means less than. As in 0≤ x< len.
- user-the-name 6y ago(3) remembering the joke