News for hackers. Stuff that matters.
Re:You'll regret using natural keys by naasking on Wednesday June 05, 2024 @07:49AM (#40583784)
> For the record: the valid chars string is 62 characters, so naively using a modulo on a random byte will technically introduce a bias

Indeed, there's no reason you couldn't just add "_" and "-" or "." as well to complete the set. Your identifier will still be URL-safe. I've been using this type of encoding for years [1] for these kinds of ids to use in URLs.

https://sourceforge.net/p/sasa/code/ci/default/tree/Sasa.Web...

Re:You'll regret using natural keys by notfed on Wednesday June 05, 2024 @12:35PM (#40587028)
- and _ tend to break text selection.
Re:You'll regret using natural keys by naasking on Wednesday June 05, 2024 @02:09PM (#40588314)
I'm not sure what you mean by "break". If you mean that touching or double-clicking on a block of text only extends up to the nearest symbols, that's true. But if your text selection UX is not terrible then it should be simple to extend that further.

That said, iOS and Android text selection have gotten worse recently, IMO.

Re:You'll regret using natural keys by Too on Thursday June 06, 2024 @02:08AM (#40594046)
Usually one is not in control over every place where text can be selected.

As a developer I will be exposed to ids being displayed in code, terminals, browsers of various sorts, database editors, json dumps, text editors, api responses, chat messages, you name it.

Re:You'll regret using natural keys by naasking on Thursday June 06, 2024 @08:13AM (#40596492)
Sure, I agree. I'm not sure what point you're trying to make though.
Re:You'll regret using natural keys by praestigiare on Thursday June 06, 2024 @08:23AM (#40596591)
Because - and _ break text selection in existing systems you do not have control over, if you use those characters your ids will become harder to select.
Re:You'll regret using natural keys by naasking on Thursday June 06, 2024 @10:09AM (#40597593)
Someone already made this point, and once again, "break" is completely undefined. It is not at all impossible or even difficult to select text with - or _, so what's "broken" exactly? At worst it takes one extra step to extend the default selection. These are such weird objections.
Re:You'll regret using natural keys by poops on Thursday June 06, 2024 @10:33PM (#40604767)
I work across multiple machines with different pointing devices (regular mouse, vertical mouse, touchpad), and have no issues double clicking to select a word. Dragging from the start of a word to the end can sometimes take multiple tries. I may miss the first letter. I may drag too far. The vertical mouse isn't great at holding a selection. It's not a huge deal, but it's an annoyance that I don't run into working with Stripe IDs.