There's a meta-problem here, which doesn't seem to have been discussed. How did the setting change in the first place? The article says:
> Then, seemingly out of nowhere...
> In my case, the “Wake for maintenance” option was disabled...
So presumably the option was originally enabled. Somehow it was disabled, resulting in the battery-draining behavior. Re-enabling it manually solved the problem. Great.
But how did the setting get changed in the first place?
I've noticed this on my Macs (actually mostly the new one; not the old, obsolete ones I still run) as well as various iOS devices. At some point I'll notice some odd, unusual, or different behavior. Hunting around in the settings, I'll sometimes find an option that seems like it should control the behavior. Changing the setting has the desired effect of restoring the former behavior. So what changed it? It's a mystery.
A memorably egregious example was the "do not disturb" setting. I normally have do-not-disturb enabled from 11pm to 7am on my phone so I'm not awakened by notifications. But one night I was awakened at 3am by my phone buzzing, because some random text message had arrived. Huh?!? The next day, working on my Mac, it seemed unusually quiet... maybe a lot of people were on vacation or something. Then I checked Slack and there were a lot of messages pending, questions put to me that went unanswered, and even speculation that I had gone on vacation. What happened? My Mac had somehow set itself to do-not-disturb from 9am to 5pm, which covers most of the workday. And my iOS devices also had do-not-disturb set for the same incorrect time interval. (Well at least I got a lot of work done.)
In this case I suspect iCloud settings synching was the culprit. My conjecture is that I logged into my iCloud account from a new device, and that device's default settings got synched to my other devices. But I'm not entirely sure.
I know I've had other cases where settings seemed to be changed spontaneously. My speculation is that OS updates will change settings. Unfortunately this isn't reproducible, and it happens rarely and with different settings. But it's happened enough times over the past couple years that it seems to be a pattern. Maybe it happened to the OP. Does anybody else experience this?
This is a very old argument. Xah Lee wrote the linked article around 2008, but previously he had posted "Why we have cons?" on comp.lang.lisp (and comp.lang.scheme) all the way back in early 1998:
Lee's post seems more of a question, but to my eye it's a "why X" question that thinly disguises an "X is bad (or ugly, redundant, useless, confusing, counterproductive, unnecessary, etc.)" argument. Essentially though it's the same topic.
The post elicited around 60 responses, among them this one from the late Erik Naggum:
which includes the following gem (or turd, depending upon your point of view):
> All in all, the pairs notion is redundant.
I hope you understand and appreciate what I have written above so the
following does not apply to you anymore. you see, I wrote it all because
I _really_ wanted to say that that sentence is the single most ignorant
and shallow-minded line that I have ever seen in any programming language
newsgroup or forum and I hope _never_ to see anybody display such utter
disregard for the brilliance and genius of people who came before them
just because they grew up in an age when "simple interface" is sneered
and laughed at in favor of "simple implementation" so any dumb fsck can
implement it right out of a "for Dummies" book.
All this is true. Note also that the C++ folks are putting a serious effort into reducing UB. See the "safe by default" section of this writeup [1]. See also my other comment [2] regarding the performance impact of this sort of change. Short answer: with sufficient optimization, smaller than one might think.
I'm a bit distant from this stuff, but it looks like C++26 will have something like -ftrivial-auto-var-init enabled by default. See the "safe by default" section of [1].
For reference, the actual proposal that was accepted into C++26 is [2]. It discusses performance only in general, and it refers to an earlier analysis [3] for more details. This last reference describes regressions of around 0.5% in time and in code size. Earlier prototypes suggested larger regressions (perhaps even "horrendous") but more emphasis on compiler optimizations has brought the regression down considerably.
Of course one's mileage may vary, and one might also consider a 0.5% regression unacceptable. However, the C++ committee seems to have considered this to be an acceptable tradeoff to remove a frequent cause of undefined behavior from C++.
The security manager was removed (well, “permanently disabled”) in Java 24. As you note, the permissions available at any given point can depend on the permissions of the code on the stack, and TCO affects this. Removal of the SM thus removes one impediment to TCO.
However, there are other things still in the platform for which stack frames are significant. These are referred to as “caller sensitive” methods. An example is Class.forName(). This looks up the given name in the classloader of the class that contains the calling code. If the stack frames were shifted around by TCO, this might cause Class.forName() to use the wrong classloader.
No doubt there are ways to overcome this — the JVM does inlining after all — but there’s work to be done and problems to be solved.
There are similarities in the problems, but there are also fundamental differences. With inlining, the JVM can always decide to deoptimize and back out the inlining without affecting the correctness of the result. But it can't do that with tail calls without exposting the program to a risk of StackOverflowError.
We've been using TCO here ("tail call optimization") but I recall Guy Steele advocating for calling this feature TCE ("elimination") because programs can rely on TCE for correctness.
ConcurrentModificationException is typically thrown from an iterator when it detects that it’s been invalidated by a modification to the underlying collection. It’s harder to check for the case described in this article, which is about multiple threads calling put() concurrently on a non thread safe object.
Interesting. I haven’t seen an infinite loop either, but I can imagine one if a comparator tries to be too “clever” for example if it bases its comparison logic on some external state.
Another common source of comparator bugs is when people compare floats or doubles and they don’t account for NaN, which is unequal to everything, including itself!
In Java, the usual symptom of comparator bugs is that sort throws the infamous “Comparison method violates its general contract!” exception.
Check out wang2200.org if you don't know about it. There is an emulator that runs on windows and osx, lots of scanned documents, many disk images, and some technical details on the microarchitecture of the various 2200 CPUs (they didn't use a microprocessor -- they are all boards and boards of TTL components, until they finally but everything on a single ASIC in the 80s).
> Then, seemingly out of nowhere...
> In my case, the “Wake for maintenance” option was disabled...
So presumably the option was originally enabled. Somehow it was disabled, resulting in the battery-draining behavior. Re-enabling it manually solved the problem. Great.
But how did the setting get changed in the first place?
I've noticed this on my Macs (actually mostly the new one; not the old, obsolete ones I still run) as well as various iOS devices. At some point I'll notice some odd, unusual, or different behavior. Hunting around in the settings, I'll sometimes find an option that seems like it should control the behavior. Changing the setting has the desired effect of restoring the former behavior. So what changed it? It's a mystery.
A memorably egregious example was the "do not disturb" setting. I normally have do-not-disturb enabled from 11pm to 7am on my phone so I'm not awakened by notifications. But one night I was awakened at 3am by my phone buzzing, because some random text message had arrived. Huh?!? The next day, working on my Mac, it seemed unusually quiet... maybe a lot of people were on vacation or something. Then I checked Slack and there were a lot of messages pending, questions put to me that went unanswered, and even speculation that I had gone on vacation. What happened? My Mac had somehow set itself to do-not-disturb from 9am to 5pm, which covers most of the workday. And my iOS devices also had do-not-disturb set for the same incorrect time interval. (Well at least I got a lot of work done.)
In this case I suspect iCloud settings synching was the culprit. My conjecture is that I logged into my iCloud account from a new device, and that device's default settings got synched to my other devices. But I'm not entirely sure.
I know I've had other cases where settings seemed to be changed spontaneously. My speculation is that OS updates will change settings. Unfortunately this isn't reproducible, and it happens rarely and with different settings. But it's happened enough times over the past couple years that it seems to be a pattern. Maybe it happened to the OP. Does anybody else experience this?