←back to thread

134 points samuel246 | 7 comments | | HN request time: 1.127s | source | bottom
Show context
ckdot2 ◴[] No.44458190[source]
"I think now caching is probably best understood as a tool for making software simpler" - that's cute. Caching might be beneficial for many cases, but if it doesn't do one thing then this is simplifying software. There's that famous quote "There are only two hard things in Computer Science: cache invalidation and naming things.", and, sure, it's a bit ironical, but there's some truth in there.
replies(11): >>44458265 #>>44458365 #>>44458502 #>>44459091 #>>44459123 #>>44459372 #>>44459490 #>>44459654 #>>44459905 #>>44460039 #>>44460321 #
1. bell-cot ◴[] No.44458265[source]
(You forgot off-by-1 errors.)

All software has to name things, and count. Caching (including invalidation) is best understood as a liability. If you can foist it off on your CPU and OS and DB, good for you. Programming whatever you're actually trying to get done is already hard enough.

replies(2): >>44459048 #>>44464137 #
2. yxhuvud ◴[] No.44459048[source]
Off by 1-errors is not part of the original quote, but is just a later addon to make it funny.

They also tend not to be very hard.

replies(2): >>44459283 #>>44459892 #
3. TeMPOraL ◴[] No.44459283[source]
Except when they're part of some base assumptions in the domain or dozen of layers of abstractions below you. They are hard to prevent from happening.
4. tombert ◴[] No.44459892[source]
They're not hard but I will say that when I was writing an app that was using both JavaScript and Julia, I kept getting off-by-one errors because Julia starts at 1 instead of 0.

Really the only time in my entire professional career that off-by-one errors have actually given me headaches.

replies(1): >>44464019 #
5. bobthepanda ◴[] No.44464019{3}[source]
I think that is from a time when popular programming languages varied in their behavior and also when people were writing for loops with incrementation all the time.

A lot of languages have just settled on zero indexing, and many now have some variation of for/each or for/of that would eliminate a lot of potential ways to encounter this error.

replies(1): >>44464952 #
6. Cthulhu_ ◴[] No.44464137[source]
If you omit the off-by-1 error from the two hard things joke, you're still off by 1, right? Kind of?
7. tombert ◴[] No.44464952{4}[source]
Yeah, I mostly will do map/reduce/filter when possible, and obviously in those cases indexes don’t matter. It could start at index 12345 for all I care with that stuff.

Occasionally, though, I need to use the same index across multiple items, there’s not a trivial means in which to zip, and at that point I have to use an old school for loop. That’s when the 1-index vs 0-index bites me.