Yeah, that's what I was suspecting.
I ended up leaning towards "download" being used in the boomer way of meaning any data transfer, whatever the direction, which in this case would more specifically be called an "upload". And that "online" was being used to mean "using a website", even though the local processing is offline.
The alternative fit to the description I had considered was a website you could give an URL, so it retrieves the zip file and allows you to inspect it remotely, and maybe just download some of the contained files, so it deals with the risk and bandwidth issues for you. That would be a different kind of useful, though it'd only be a few days before someone uses it for malign purposes and gets the site operator a no-knock visit from the fuzz, so that seemed much less likely.
I can see a use for an app that can be used where they can't be installed, though.
I'm confused. How are you defining "download" and "online" here?
The website suggests that the server holds the files and does the extraction:
Extract and Explore compressed files online [emphasis mine]
which fits with the github claim of:
to view and extract zip files online without downloading them
but the website also states that:
nothing leave your browser
which suggests that the server has nothing to do with it, and you do actually download the zip files first.
What am I missing?
You have to remember the puritanical roots of the country.
The upper/middle/lower class distinctions are not economic:
- upper = rich;
- middle = comfortable;
- lower = poor.
They're instead based on morality:
- upper = blessed;
- middle = virtuous strivers;
- lower = good-for-nothing work-shy losers.
The upper class have been divinely marked for better things. They are never helped. Everything they receive is ordained. The lower class are scum who it would be wrong to ever help, since it would only encourage their inherent unwillingness to work. The middle class, then, are the self-made people who work hard for what they get and obviously deserve a little more, which in self-image terms is basically everyone.
Politicians promising to help the middle class are, therefore, declaring that they will reward the worthy (and punish the unworthy), which is a popular sentiment.
Hello again, Auntie.
I wrote for advice some time ago \[Confused in Claremont\], and just getting the problem out there was so renewing, I felt the need to ask a follow-up question that has also been bothering me. You see, sometimes I disagree with the free-speech advocates, and that goes even worse!
For example, to the previously mentioned "sunlight is the best disinfectant" claim, I will just ask the question: "Isn't drowning in bleach actually the best disinfectant?" (The manufacturers always tout its efficacy and, as a believer in free markets, it's important to take every marketing claim at face value. And no one's selling sunlight, are they? So that must be useless.) But they don't like this either; I can't win! And when I also point out that drowning in bleach has the added benefit of wide applicability, the liberal objectors call me "murderously uncivil". But do you know what happens if you don't drown germs in bleach? You get a stinky toilet. And what's civil about that? Or cholera?
And as for the objectors who "lean right", well, they start to shriek in what sounds like German? This is America, buddy. Speak English. I think they call me a "radical extremist", but this is just plain wrong. Like them, I'm an apolitical centrist who just thinks it's important to hear out opposing voices and pave the way to a future in which all the people whose existence irks me have died gruesome, agonising deaths. Really, I'm exactly like them, which they keep saying is important, but when I try putting some contrarian viewpoints out there myself, it always goes badly. Clearly, I'm doing something wrong, but what?
I really do try to stick to the mantra of "facts don't care about your feelings" but these guys always seem really angry whenever I try to join in with any evidence of reality at all. I don't get it.
Yours as ever,\ Perplexed in Peoria
Dear Aunt Chapo,
From time to time, I encounter self-described "free speech advocates", who make the claim that "sunlight is the best disinfectant". This is usually the most agreeable part of their claims, and so I will respond positively: "yes, the only truly effective treatment is exposure to lethal doses of radiation", but they always react as if that isn't what they meant.
This leaves me confused, because if what they actually meant was that the best way to deal with a dangerous pathogen is to internalise it and every poison it produces, surely at least one of them would have said "phagocytosis is the best disinfectant", but they never do. It's always "sunlight", and the mechanism of action there is definitely deadly radiation.
Now, they're obviously not saying that the appropriate response to an invasive organism set on hijacking the host's systems in order to reproduce itself unchecked with the ultimate result of killing the host is to suppress the immune system, sit back, and let it do whatever it wants, because that's insanely suicidal. Yet I often get the feeling that this is what the advocates do actually want. Like I say, I'm confused.
Are they actually saying that we should send nazis to tanning salons or off on a warm holiday for some UV exposure? They do tend to look pale, you know?
Anyway, I'm sure your advice will be as helpful as ever.
Yours,\ Confused in Claremont
Are there any art or maker groups in your area? If you can get to one (or more) of those, there are going to be people who will fall over themselves to talk to you if you just ask them about what they've made.
People love when someone shows an interest. You don't need to know anything (or pretend to know anything) beforehand, and the same few questions/prompts can be reused: from a vague "tell me about [the thing you made], to "what was the hardest part?", "how did you do this bit?", "did you learn anything cool along the way?", "what do you think you'll make next?" So long as your interest is genuine and you actually listen to what they say, you can't really mess things up.
And if you want to make anything yourself, regardless of your current abilities, such groups tend to be quite nurturing, where someone will show an interest in you too. Art in particular is an expressive pursuit that attracts lefty weirdos. The desire to connect with people is right there for you to be a part of.
the intent of the code is to get the previous month RELATIVE to the current date.
But that isn't what it does. From the original post:
function getMonthName(monthNumber) {
const date = new Date();
date.setMonth(monthNumber - 1);
return date.toLocaleString([], { month: 'long' });
}
That is a function which is meant to take a number (presumably 1 to 12) and return a localized name for it. This is essentially an array lookup and should return the same output for a given input (and locale) every time it is called. If the intent is to return a value relative to the current date, it is even more wrong, since it should gather the month from the current date, not the function paramenter. This claim of intent, not present in the original post, is an example of you changing your story over time.
Yes, it would help find the problem faster because the first time invalid date is passed in the program will crash.
No, it wouldn't. As I have said before, testing for unexpected return values is just as effective as testing for errors, that is, not very with the function originally presented under sensible assumptions. If the function actually did look like the intent you claim, the tests would be different, necessarily replacing Date
for consistent runs, but would be equally likely to catch the problem whether failing on value or error. And if you are eschewing testing and relying on runtime crashes, you have bigger problems.
Given that I have agreed and commiserated, and neither of us can change JavaScript, there is nothing to be gained from pursuing this complaint. In contrast, what I have tried to say, if followed, would give you an approach that leads to more reliable code, even in the face of undesirable APIs.
I had thought that worth pursuing, and had thought you worth investing my considerable time. Alas, I can only lead you to the water...
I'm not missing your points, even as you change them. I've agreed that JS sucks. I've agreed that errors can be more helpful. I'm not trying to argue with you about that. What I have said, from the beginning, is that in the code you originally presented a behavioural change for setMonth
will not help you find the problem any faster. Test failures for the wrong output occur just as often as test failures for errors, on exactly the same few days each year. The API change gives no advantage for the specific function this discussion started with in this regard. However, an approach that avoids inconsistency will, because in this particular instance, that is the real source of the problem. That is all.
In that context—the one you started with—it does not matter that there is often good reason to call Date()
without arguments. The getMonthName
function presented, effectively an array lookup, should produce the same output for any given input every time. It has no reason to engage in any behaviour that varies from day to day.
There is absolutely nothing wrong with getting the current date.
Bluntly, the code you presented fails precisely because it gets the current date where it should create a more specific one, and then fails to deal with that variation appropriately. You can keep distracting yourself with language design decisions, but that won't help you avoid this particular type of problem in the future because that's not where it is.
Getting the current date is often fine. In this specific instance, it is not. That is why the function doesn't work. If you are missing that point, as much as I appreciate your enthusiasm in continuing the conversation, I will take the L (and the code that actually works) and move on.
Yes, and I've said that I agree with that in general. I know that this isn't hypothetical; that's exactly why I keep saying that throwing an error doesn't help you find this bug early at all.
Even the silent weirdness can be caught by the most basic of tests checking output against input, but only if your function works the same way on every invocation.
Whether making a giant fuss (as you'd prefer) or making the best of it (as it actually does), the setMonth
method always works the same way. My code always works the same way. The setDate
suggestion makes the code always work the same way.
Code that always works the same way is easy to test.
If the day of the month is constant and incompatible with setMonth
, whether there's a thrown error or just an unwanted return value, a simple test will reveal that on every test run. If the day of the month is constant and always compatible with setMonth
, the test will pass appropriately on every test run.
The bug in the code you originally presented comes from working differently over time. That's why, most days, tests won't identify the problem, even with a fussy, noisy API. Most testing days, the date will just happen to be compatible, and even the fussiest, noisiest API will carry on without any mention of the problem.
The reason the original code works differently over time has nothing to do with the silent, unexpected behaviour of setMonth
. It's entirely down to calling Date()
without arguments, the entire point of which is to give different values over time. That call effectively introduces state that is not controlled by the function. And not bringing it under control is the real source of the bug.
Yes, absolutely, JavaScript sucks. Make F# the only supported web scripting language! But JavaScript's suckiness is not the cause of this particular bug. JavaScript's suckiness is not the reason this bug is hard to catch. The real problem lies in code that functions differently over time when it should (and could easily) be consistent. That's what actually makes it hard to test.
Plenty of other languages and API design choices still allow code that functions that work differently over time, which is why, as justifiable as the complaints are in general, those factors are irrelevant for this particular bug. Write code that always works the same way and the problem goes away. That's the real core of the issue.
Obviously, that's easier said than done, and it's irritating that neither loud errors nor most testing will help you in this regard, but that's the way it is.
I agree with you that errors are useful feedback for coders who don't know the ins and outs of an API. And every programmer is in that group at some point. But the difficulty in identifying this particular bug doesn't stem from the API decisions.
Whether Date
s throw an error, or work with what they're given, has no bearing on the subtlety of this bug. Either way, tests that don't replace Date
will fail to identify it most of the time, and tests that do, based on its use within the function, would be called wrong-headed by many.
Either way, the bug only shows up at the end of months longer than the target month, and that infrequency has nothing to do with the peculiar design choices of the Date
API. It stems exclusively from the evaluation of Date()
called with no arguments returning different values at different times—behaviour you have not objected to, and which I'd expect to be considered entirely appropriate, in fact its very point—combined with an attempt to use that value, whatever it may be, without due consideration.
Since the month is the only part of interest, there's no reason to allow the other parts to vary at all. Fixing them, as I suggested at the beginning of all this, is the simplest approach, but setting them first, as has also been suggested, would work too.
You can once again complain about JS design decisions and I'll agree about many of them, but, as much as you might like it to be, and as annoying as so many of us think they often are, here it is beside the point. The perniciousness of this particular bug stems from unnecessarily calling a function with inconsistent output and then improperly processing that, instead of using a function call with always-predictable output.
I've tried to point that out in all the ways I can think of, so if it's still not getting through, I give up. And if your acknowledgement was too subtle for my sleepy brain, and I've ended up overexplaining, then I'm sorry.
I was taught that side effects are not so one-sided, and that changing output in response to outside state (such as the date) is also a side effect, a side effect on the function, rather than a side effect of the function, but I'm happy to use other definitions so long as they're commonly understood.
As I said before, though, even if JavaScript did throw an error as you'd prefer, it would still allow your function to have date-based problems. They'd be a bit noisier perhaps but no less present, and just as "well it's worked fine so far". And that's because, as I keep saying, the real problem here is using a function with inconsistent output and not thoroughly dealing with the possibilities. An API change wouldn't alter that. Most of the time it would still let you write bad code.
I also probably agree with you that errors are generally better than silence in response to bad input but, as someone else has said (more or less) it's not always unreasonable to consider "31st [Month]" as 31 days after the end of [Previous Month]. Without throwing errors, this flexibility is possible. Perhaps the creators believed having to mutate the day-of-month first was an acceptable trade-off for that.
You've replied while I was editing, so see that regarding what I mean by side effects.
As far as throwing an error when you try to create "31st February", this wouldn't actually help much, since the error would still only occur on some days of the year, because your original code doesn't account for the range of outputs from Date()
when called without arguments.
To perform correctly, your code needs to normalise the day of the month, or just create the date more explicitly to begin with, but this is a calendrical issue, not a JavaScript one.
The rake has nothing to do with JS (which I agree is cursed, but for its own reasons, not this).
You have called a function in a way that does not give a consistent value (Date()
). Such functions are hardly the preserve of JavaScript. You've failed to adequately deal with the range of values produced, with code that tries to insist that the "31st February" can be a meaningful date in February. You should accept that this is your mistake and learn to (better) avoid side effects where possible.
Also, the function isn't side effecty since it doesn't make implicit references outside its scope.
Edit responding to your edit:
Also, the function isn't side effecty since it doesn't make implicit references outside its scope.
The Date()
function's output varies according to something other than its input (and even the rest of your program). Using its output without accounting for that variation means that your function, as originally written, also gives inconsistent return values, varying according to something other than its input, because it does, in fact, reference something outside the function. If it did not, the results would only depend on the monthNumber
argument, and would always be consistent. I don't know what you call that, but I view it as a side effect.
As you have said, the rake is that months have different lengths, and you need to account for that. But that's not one of JavaScript's many issues.
You want to create the date "31st February", but it's JavaScript that's cursed?
Write a less side-effecty function.
function getMonthName(monthNumber) {
const date = new Date(2023, monthNumber - 1, 1);
return date.toLocaleString([], { month: 'long' });
}
After getting the lightning-strike timing wrong, Marty McFly has waited decades to finally prove that the "kids are going to love it".
Their physiology is barely diverged so their intellects are likely to remain similar. Espionage is frequently the theme of Romulan encounters, which would help keep them up to date. And if they procreate more frequently than every seven years, they might have a much larger population even with greater murderousness, with more people being advantageous for tech development.
It's a Klingon moon that's doing just fine.
I remember having to pause the video after that second bit. The piled-on criticisms, so matter-of-factly delivered, needed some recovery time. Your assessment is spot on.
What I know mostly comes from the Folding Ideas video about him.
Most replayed part
Nostalgia Critic: I have become comfortably dumb.
Dan Olson: And, you know what, I’m not going to disagree. You said it, man. I don’t know if it works as self-deprecating humour because I don’t think it’s comedically true, I think it’s just true.
— "The Nostalgia Critic and The Wall", 34:28
Anyone who would judge you for that isn't worth pretending for. Look stupid. It's fine.
It's bad enough when student 'conservatives' play this "I am the master debater" game (with the most bad-faith approach, and without any understanding of real debate) but, when they're in their thirties, it's even more pathetic.
Since the XSS incident a couple of weeks back, I hadn't been able to log in, or even sign up for a new account. All attempts at either ended with the spinning bear. Now, presumably because of the upgrade, I have been able to create a second account to post this, but I can't log in to my original account, AppelTrad, because it prompts for 2-factor authentication.
This is (partially) my own fault, I suppose, for clicking the checkbox and not mentioning that it didn't actually give me any of the promised results, while I was still logged in; since I was also able to untick the box without being prompted for anything, I just assumed it was a bit of not-yet-implemented UI and that I had reset the option for if it ever became effective, and carried on without any problems until the forced logout.
Since "2FA being broken is a known issue", I'm wondering: is it possible for an admin to reset that field in my database record (or whatever needs to be done to cancel 2FA) without any of the security shenanigans that should accompany working two-factor authentication, so I can successfully log in again? (I have my passwords saved, so it's not just a mistyped password issue.)