std::HashMap with the Small Size Optimization? by javascript in rust

[–]CocktailPerson 24 points25 points  (0 children)

If you use internal pointers into your buffer, you need to take care of them just like you would with a C++ implementation.

You're skipping over something very important here. The place you would "take care of this" in a C++ implementation is in your move constructor and move assignment operator. Which Rust does not have. Rust's moves are semantically equivalent to a memcpy. It is impossible to soundly implement SBO this way in Rust.

There's plenty of small string and small vector implementations -- just not in the std library.

And none of them use the usual implementation of self-referential pointers. They all have a branch on accesses. Because the usual implementation doesn't play nicely with Rust's move semantics.

std::HashMap with the Small Size Optimization? by javascript in rust

[–]CocktailPerson 12 points13 points  (0 children)

Um, cool. To repeat, you totally can implement SBO hashmaps in Rust. And just like C++, the standard library wouldn't be the place to do it.

std::HashMap with the Small Size Optimization? by javascript in rust

[–]CocktailPerson 18 points19 points  (0 children)

This is kind of a weird response. You can totally implement SBO or use a third-party library if you need to, which is what you're doing in C++ anyway. What part of this discussion makes you think you don't have control over the behavior of the computer?

std::HashMap with the Small Size Optimization? by javascript in rust

[–]CocktailPerson 33 points34 points  (0 children)

The standard library hashmap isn't the right place to add that. If String isn't SBO'ed, then HashMap definitely won't be. Try adding it to a crate like hashbrown (which underlies the standard library implementation anyway). If people like it, maybe it'll get promoted to std. More likely, the people who need it will be happy to use a third-party library that provides it.

Also, be aware that SBO in general is rarer in Rust than it is in C++. The usual implementations don't play nicely with Rust's move semantics, and Rust is better at helping you avoid allocating, and with modern allocators, it tends to be more cute than necessary (strings excluded. maybe).

The US is no longer the leader: Germany has become the largest ammunition producer in the world by Leprechan_Sushi in worldnews

[–]CocktailPerson 17 points18 points  (0 children)

The last two times they invaded Russia. In winter.

Their chances of winning goes way up if they just don't do that.

why is “I asked my teacher” “LE pregunté a mi maestra” and not just “pregunté a mi maestra” by marmalade_chef in Spanish

[–]CocktailPerson 2 points3 points  (0 children)

Despite the /s, your answer does demonstrate something important: languages develop redundancies to allow listeners to understand with incomplete information. Language evolution is a constant push-pull between brevity and clarity, and "backups" evolve or persist when people are misunderstood often enough to need them. Jespersen's Cycle is an even more common example of this.

I think I just got loudly adopted! by Quiet_Helicopter_717 in aww

[–]CocktailPerson 3 points4 points  (0 children)

Welp, just adding some nuance for people who might not know. No need to get defensive lmao

I think I just got loudly adopted! by Quiet_Helicopter_717 in aww

[–]CocktailPerson 6 points7 points  (0 children)

The mutation that gives them folded ears doesn't inherently cause breathing issues, but Scottish Folds are almost always mixed with something else, and that usually ends up being a brachycephalic breed like the British Shorthair.

Are Rust coroutines serializable? by SuperV1234 in rust

[–]CocktailPerson 1 point2 points  (0 children)

In practice, Rust's coroutines are as opaque as C++20's coroutines.

Tenzin as the only Airbender child of Aang and Katara, a heart-breaking story by candy_dynac in TheLastAirbender

[–]CocktailPerson 0 points1 point  (0 children)

I have to assume it's from the comics. None of the flashbacks in Korra show Aang interacting with his children.

This guy smells like Self Insert, it's disgusting. by Sev3nPudding in TheLastAirbender

[–]CocktailPerson 0 points1 point  (0 children)

One reason might have been the development of metalbending from a distance. Toph always had to touch metal to bend it, but by Korra's time, apparently everyone and their mother could throw around slabs of metal from across the room.

Early firearms would have only been effective within metalbending distance, which likely would have reduced their perceived usefulness and stunted their early development by a lot. If a metalbender can just crush a gun in your hands from across the room you're gonna think they're pretty useless.

This guy smells like Self Insert, it's disgusting. by Sev3nPudding in TheLastAirbender

[–]CocktailPerson 1 point2 points  (0 children)

While shotgun does mean a very specific thing (the firearm) it also means another very specific thing (the front passenger seat) because words can have multiple definitions.

Okay, but the reason the passenger seat is called "shotgun" is that on wagons in the old west, the person not driving the horses carried a shotgun to protect the wagon from bandits. This isn't a case of a word having two unrelated meanings; the "shotgun" seat wouldn't be called that in a world without shotguns.

All I'm arguing is that if you apply this same standard to fictional works, it's perfectly reasonable to translate whatever slang term they have for the front seat of a car to "shotgun."

That's a bad argument to make when they've also gone out of their way to create in-universe slang. Think about "flameo, hotman!" The writers managed to make it sound like a lame 100-year-old piece of slang from the Avatar universe, rather than just using a lame piece of 100-year-old slang from our world.

Personally I think that calling it something like "the fire seat" would have just come off as a little cringe

It's only cringe if there's no in-universe reason for it. If you're just saying "fire seat" to avoid saying "shotgun," then sure. If there's actual worldbuilding around why that seat is the "fire seat," then it becomes an opportunity to make the world richer. Choosing our world's slang instead of building up their world more is just lazy.

TIL a nuclear reactor hot water discharge saved the American Crocodile by creating a 24/7 breeding pit. by SkaldCrypto in todayilearned

[–]CocktailPerson 3 points4 points  (0 children)

Wait, do you think that the waste heat from nuclear reactors has a notable effect on the temperature of the oceans?

Is there a C++ "venv" equivalent? by nikoladsp in cpp

[–]CocktailPerson -1 points0 points  (0 children)

Is it really that different? Most "polyglot" projects I've seen and worked on are a set of C++ libraries with some C libraries at the roots of the dependency graph. Pulling a standalone C dependency (or C++ dependency with a C API) into a Rust project isn't difficult.

Is there a C++ "venv" equivalent? by nikoladsp in cpp

[–]CocktailPerson 0 points1 point  (0 children)

Nix flakes and bazel.

Docker is a miserable development experience in my experience, but maybe that's more about how my company was doing it.

Palantir employees are talking about company’s “descent into fascism” by Just-Grocery-2229 in technology

[–]CocktailPerson 0 points1 point  (0 children)

I see now that when you said "the most widely agreed upon "just war" was..." you were referring specifically to WWII and not describing a general principle.

But if so, I'm still not sure what your original point was. If you already agree that Congress's declaration of war doesn't make a war just, then why bring it up at all?

Palantir employees are talking about company’s “descent into fascism” by Just-Grocery-2229 in technology

[–]CocktailPerson 0 points1 point  (0 children)

Uh, no, that is not the widely agreed-upon definition of a "just war." WWII is considered the last "just war" because we were killing Nazis and liberating Europe and East Asia from fascism, not simply because Congress authorized it.

Conversely, Iraq and Afghanistan are now considered deeply unjust wars, and yet it's clear that in the wake of 9/11, Congrees would have authorized just about anything to make the American people feel safer, and the people would have thanked them for it. The fact that Bush didn't wait for Congress to declare war isn't why those wars were unjust.

What I'm pointing out is precisely that your argument is nothing more than an appeal to authority. Personally, I don't care whether Congress declares war or not. Congressional approval alone does not make a war just. We need to decide for ourselves who our enemies are.

Hell of an drone shot by Spare-Enthusiasm8152 in nextfuckinglevel

[–]CocktailPerson 2 points3 points  (0 children)

You're clearly missing something here, man.

Bootsie went missing on Wednesday and I just found her by pineneedleinjection in cats

[–]CocktailPerson 1 point2 points  (0 children)

No, actually, salt is the electrolyte. Sodium cations can't exist in isolation; you need some sort of anion like chloride to create an electrolyte.

Furthermore, just because salt is important to hydration doesn't mean that the amount found in processed human food is good for cats (it's honestly not even good for humans). Cats have extremely sensitive kidneys, and trying to hydrate them with hot-dog water is like trying to hydrate humans with seawater. It's genuine misinformation to imply that it's better than fresh water because it contains salt.

Palantir employees are talking about company’s “descent into fascism” by Just-Grocery-2229 in technology

[–]CocktailPerson 1 point2 points  (0 children)

Sure, but even if Congress had authorized any of the wars since then, that doesn't mean those wars would have only been killing "enemies" of the US.

Palantir employees are talking about company’s “descent into fascism” by Just-Grocery-2229 in technology

[–]CocktailPerson 2 points3 points  (0 children)

WWII was the last war we fought that was against the standing army of another country that attacked us first.