timhh

joined 1 week ago
[–] timhh@programming.dev 4 points 5 days ago

I’m guessing there’s a reason they wanted min() to be able to be called without any arguments but I’m sure it isn’t a good one.

It not a totally unreasonable definition. For example it preserves nice properties like min(a.concat(b)) == min([min(a), min(b)]).

Obviously the correct thing to do is to return an optional type, like Rust does. But ... yeah I mean considering the other footguns in Javascript (e.g. the insane implicit type coersion) I'd say they didn't do too badly here.

[–] timhh@programming.dev 2 points 5 days ago

Completely wrong. I'm hoping this was a joke... :-D

[–] timhh@programming.dev 0 points 1 week ago

You can't store data in parity bits... so it's irrelevant.

[–] timhh@programming.dev 2 points 1 week ago (2 children)

It's not just less memory though - it might also introduce spurious data dependencies, e.g. to store a bit you now need to also read the old value of the byte that it's in.

[–] timhh@programming.dev 2 points 1 week ago (12 children)

I don't think so. Apart from dynamically typed languages which need to store the type with the value, it's always 1 byte, and that doesn't depend on architecture (excluding ancient or exotic architectures) or optimisation flags.

Which language/architecture/flags would not store a bool in 1 byte?

[–] timhh@programming.dev 5 points 1 week ago* (last edited 1 week ago) (10 children)

No it isn't. All statically typed languages I know of use a byte. Which languages store it in an entire 32 bits? That would be unnecessarily wasteful.

[–] timhh@programming.dev 23 points 1 week ago (4 children)

Well there are containers that store booleans in single bits (e.g. std::vector<bool> - which was famously a big mistake).

But in the general case you don't want that because it would be slower.

view more: ‹ prev next ›