[-] timhh@programming.dev 1 points 4 days ago

There are a few reasons you shouldn't use this in proper programs. If you're the sort of person that thinks hacky Bash scripts are acceptable then sure, use it there.

  1. It isn't cross-platform. Not available on Mac/Windows.
  2. There are several types of UUID with different properties. This doesn't let you choose which one to use.
  3. To make programs deterministic (really useful for testing!) you want to be able to seed all their randomness with a specific seed so that it generates the same UUID each time you run it. (Obviously in normal use you would use a random seed.)
[-] timhh@programming.dev 10 points 1 week ago

Yeah but please don't actually use this. Use a proper UUID library that works cross-platform and lets you choose the UUID type and can be seeded etc.

[-] timhh@programming.dev 15 points 2 weeks ago

Catchy. Can't imagine why "algorithm" caught on instead.

[-] timhh@programming.dev 3 points 2 weeks ago

By that measure basically every StackOverflow question asking how to do something is opinion based - the very nature of the site is questions asking for the best solutions. The "opinion based" rules is NOT meant to prevent questions like this. This is the kind of useless pedantry that killed StackOverflow.

I think it comes from a fundamental disconnect. You have something like:

  1. People ask questions like "which programming language is best" or "what's the best game engine" or "should I use tabs or spaces"?
  2. Someone decided they didn't want StackOverflow being used to debate these things, so they made a rule against opinion-based questions.
  3. People later come along and blindly apply the rule to ban anything that is worded as if it is an opinion, even if it's a perfectly suitable question.

not sure why that wasn’t enough for you

I never said it wasn't; just that it shouldn't have been closed.

Just because it’s closed doesn’t mean the answers already provided are bad.

Again, I never said otherwise. The point is it shouldn't have been closed.

[-] timhh@programming.dev 10 points 2 weeks ago

My favourite closed question is how to do Case-insensitive string comparison in C++ - closed as opinion based!

ChatGPT helped, but this is why you died StackOverflow.

[-] timhh@programming.dev 4 points 2 weeks ago

I disagree. I still easily find new questions to ask, for example this one which is a nice demonstration of why StackOverflow is dying. Or this one (which also received 4 downvotes).

Even so, I definitely go to ChatGPT first now. Now that we finally have an alternative to the toxic downvotes/closing, why would I go there unless I absolutely need to?

[-] timhh@programming.dev 2 points 2 weeks ago

I think he's talking about if a variable only exists in registers. In which case it is the size of a register. But that's true of everything that gets put in registers. You wouldn't say uint16_t is word-sized because at some point it gets put into a word-sized register. That's dumb.

[-] timhh@programming.dev 4 points 2 weeks 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 3 weeks ago

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 3 weeks ago

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 3 weeks ago* (last edited 3 weeks ago)

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 24 points 3 weeks ago

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: next ›

timhh

joined 3 weeks ago