Hacker Newsnew | past | comments | ask | show | jobs | submit | jdthedisciple's commentslogin

> Upsert (https://github.com/tc39/proposal-upsert): [Weak]Map.prototype.getOrInsert(), [Weak]Map.prototype.getOrInsertComputed()

Their usage of upsert appears different than I was used to:

Me: Upsert = Update or Insert

Them: Upsert = Get or Insert


The proposal used to do more thing and we didn't change the URL after we ultimately arrived at this set of APIs.

> Their usage of upsert appears different than I was used to: > Them: Upsert = Get or Insert

I agree that their choice of labeling the proposal as "upsert" is less than ideal. However, this functionality is reminiscent of a very useful Perl capability known as autovivification[0] as described in the motivation section:

  A common problem when using a Map or WeakMap is how to 
  handle doing an update when you're not sure if the key 
  already exists in the map.
0 - https://en.wikipedia.org/wiki/Autovivification

Reminds me of the weird C++ map operator[] behavior.

If you use that operator and the value doesn't exist, it'll default create one and return a reference to that.

And as I'm writing this I realize why... references cannot be `null`.


what is the value of an "update or insert" call on `Map`? is that not just set?

`getOrInsert` here seems to be the Python "set_default" method on dicts, which is very useful at avoiding tedium in some basic data munging


I do this all the time, getOrInsert would come really handy: you need something from a Map-backed storage, but the value may be unset, so you first check if it's undefined, set the default value, and then use that.

Example:

    update(store, (draft) => {
      if (!draft.alertConfigurations.has(req.params.clusterId))
        draft.alertConfigurations.set(req.params.clusterId, new Map());
      const clusterAlerts = draft.alertConfigurations.get(req.params.clusterId);
      req.body.forEach((alert) => clusterAlerts.set(alert.id, { ...alert, predefined: false }));
    });

> what is the value of an "update or insert" call on `Map`?

It gives a caller the option of alternate logic based on the existence, or lack thereof, of a value.

> is that not just set?

No. The semantics of a "set" operation would overwrite an existing entry (if one exists).


I wonder how extensive the overlap is with sacred-texts.com

Great article but I don't get their insistent on "inefficiency":

They start out saying oxygen vessels partially and subtly occludes vision.

So the bird's eye doesn't suffer from this disadvantage.

In other words: It uses 15x more energy but presumably also sees 15x sharper and more into the distance than our human eye.

Sounds proportional at most, but certainly not inefficient for the bird's purposes?


Every mention of efficiency is about the chemical process, not about vision as such.

> anaerobic glycolysis that is significantly less efficient than oxygen-powered metabolism

> Oxygen molecules make energy production in cells extremely efficient.

> the presence of oxygen makes energy extraction from a single glucose molecule 15 times as efficient, and sometimes more.

> This energetic ability is powered by an inefficient metabolism.

> This suggested that the strange structure wasn’t bringing oxygen into the bird’s retina; rather, it was helping to pump glucose in, thereby enabling the less efficient anaerobic process.


You cannot ignore the tradeoffs and the output produced:

> Though we normally can’t perceive them, these vessels always occlude a portion of what we see, and for an important reason.

Efficiency is input / output, not just input.

15x input / 15x output is just as efficient as 1x input / 1x output.


You complained about the article's talk about "inefficiency" -- you quoted it. But as I noted, THEIR mention of efficiency/inefficiency was ALWAYS about the chemical process, not about efficiency of vision. Now you're totally moving the goalposts. I don't understand why you're playing such an obviously absurd game but I will leave you to it.

?? why the nastiness?

I'm not moving goalposts. My 2nd comment just adds detail, which i hoped the reader would manage to infer based on my 1st one. That's all.

My point is it's like saying a car is more inefficient than a bicycle because it uses (more) fuel... totally ignoring that it also gets you much further and that too much faster.

Whereas a valid, to me, criticism would be that a particular car is less efficient than another car bc it burns more gas, when both do about as good a job.


I don't think the article asserts that the better bird vision is primarily due to the absence of occluding blood vessels, although that is an advantage.

Scientists noted that the bird eye produces good results with a less efficient process. This article is only about the explanation for that. Presumably they would have been just as interested if a human level eye also operated without oxygen.


As many have correctly pointed out: A reasonable person cannot pass blanket judgement on many of the entries shown.

This also highlights a major flaw with voting and political campaigning in democracies:

Undifferentiated blanket judgements based on biased framing, polarizing society artificially into totally unnecessary camps of opposition.


Couldn't have said it better, felt the same way about it.

Another example is military and defense, or pharmaceuticals. Some rather beneficial and even necessary aspects to both, yet some disagreeable things to either as well.


If this was framed as things you'd eliminate from society tomorrow, maybe pharma would fair better

most likely the culprit indeed


But I used nonstandard nonces!


Seems up again. How briefly did the outage last?


Unfortunately, Internet + Smartphones have invalidated 2.

"Why don't you just google it yourself?"


of Claude's consciousness, you mean ... ??


Yes.


Yeah, and clever Hans is able to understand human speech and do calculations.

https://en.wikipedia.org/wiki/Clever_Hans


I tried this on GPT 5.5 on a peivate unpublished personal excerpt and it correctly guessed: "The most likely author is you".

I suspect this is what's going on in most of these cases.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: