Live data from Hacker News

URLs are state containers

alfy.blog

211–218 of 218 posts

Re: URLs are state containers

#211
post #136

Earlier quoted context omitted.

Restoring state is just one of the features, that can be implemented in any app if needed, with all that baggage that comes with a feature – testing, maintaining, etc. It's just if desktop app becomes so broken/unresponsive, that the only way is to restart it – we consider it a bad experience and bad software. On web "restarting the app" is a normal daily activity when something goes wrong with state/layout/fields/fo…

Most desktops apps are buggy enough to occasionally require restarts or even crash. I don't currently use any program that never crashed on me. On the web "restarting the app" is seamless and not imply anything wrong happened. It's like the Erlang approach to errors, but on steroids The trouble with leaving restoring state to the application do as they wish is that most of times they will get it wrong. Also most of t…

My experience has been different – and increasingly so over the past 30 years. Crashing or leaking desktop apps are a rare experience nowadays. When it happens, it’s always an "oh, really?" moment. On the web… I often can’t even write a Facebook comment without refreshing the page.

Good defaults definitely matter. But not overloading an app with functionality matters as well. Matching feature sets to actual user needs also matters.

The problem with state restoration is that it’s one of those features that looks simple, yet can be extremely tricky to implement correctly – the point you already made. And there’s no single solution that will fit all cases, or even 80% of them. Restoring scroll position is one thing, but restoring an unfinished video editor timeline is another. Both look deceptively simple ("I just reopened the crashed app and it opened at the exact same state"), but the internal mechanics require wildly different mechanisms and trade-offs.

I do agree, however, that frameworks and SDKs should provide properly designed mechanisms for state restoration – and they often do (like the State Restoration API on iOS/macOS).

But the argument that "state restoration should be default and provided by the environment" feels like post-rationalization of the existing mechanics.

> It’s like the Erlang approach to errors, but on steroids

The Erlang approach was intentionally designed that way. Web apps’ normalization of "restarting" is just a testament to how normal buggy software has become in the web ecosystem. Anyone who has ever tried to buy tickets online or register through a simple form on a government website knows that even for such common use cases, it’s extremely hard to create a good user experience. There are some fantastic web apps nowadays, and government-backed design systems and frameworks that sometimes match native apps’ experience – but that only proves the point. It takes an enormous amount of effort to make even simple things work reliably on the web stack.

The core reason, of course, is that the "web stack" is a typesetting engine from the ’80s that was never designed for modern UI apps’ needs in the first place. Why we still use a markup language to build sophisticated UIs and think it’s fine is beyond me. I recently saw an experiment where someone played a video in Excel, using spreadsheet cells as pixels and a lot of harness code to make it work as an output device. It’s doable, but Excel was never designed for that. No matter how many layers of abstraction we put on top – or how many ExcelReact frameworks we create – the foundation is simply not right for the task.

And yet people continue to justify the “defaults” of the web stack as if they were deliberate design choices rather than byproducts. Like, "it’s so good that everything is zoomable," or "I like that everything is selectable". Which sounds fine – until it doesn’t. Why on earth would I need to select half my widget tree with a 3-pixel mouse shift? And when I really do need to select something, it often doesn’t work properly because developers take it for granted and never verify or test it.

Or zooming – whenever I zoom a Facebook page to write a comment, the view keeps jumping around because some amazing piece of JS crapcode decides to realign the interface on a timer (to show ads?). Nobody on Facebook’s QA team probably even tests how the comment section works when zoomed in Safari. The web app experience is simply one of the worst, due to this messy feature set people call "good defaults". And as someone who also has to write web apps from time to time, I can’t stress enough how disproportionately more effort it takes to make an app with sane, good default behavior.

(P.S. There are some good things in the current state of the web stack – but they’re mostly the product of the industry’s sheer size, not the stack itself.)

Re: URLs are state containers

#212
post #186

Earlier quoted context omitted.

> I genuinely don't understand why people don't get more upset over hitting refresh on a webpage and ending up in a significantly different place. It's mind-boggling and actually insulting as a user. Or grabbing a URL and sending to another person, only to find out it doesn't make sense. I do dislike those cases. But I also dislike being two-thirds through a video or page, thinking “I’ve got to share this with , it’s…

I understand the inconvenience to have to leave a keyboard-driven workflow but I think the Share button --> Copy link are common enough now that it shouldn't be an issue. I know firefox also has "Copy clean link" if you right-click on the urlbar. I did not find an extension that does just that but it should be trivial to create one and assign a shortcut to it.

Except when it's not implemented properly and it breaks other workflows. For example, if it only shows a button (not a link or a tag) and copies the link to the clipboard via JavaScript, consider this scenario: I want to send this "link" to my other computer using Firefox's built-in Send Page to Device feature. I have to click Share, click the copy to clipboard button, open a new page, paste the URL, and only then can I share it.

If the state were stored in the URL, I could do it in two steps: open context menu -> Send Page to Device, and I'm done.

Re: URLs are state containers

#213
post #205

Earlier quoted context omitted.

What makes them annoying to share? I bet it's more an issue with the UX of whatever app or website you're sharing the link in. Take that stackoverflow link in the comment you're replying to, for example: you can see the domain and most of the path, but HN elides link text after a certain length because it's superfluous.

SO links require just the question ID; short enough to memorize.

Sure, but the SO link was just an example. HN does it with any link, like this one which is 1000 characters long:

https://example.com/some/path?foo=bar&baz=bat&foo=bar&baz=ba...

If the website or app has a good UX for displaying/sharing URLs, the length doesn't really matter.

Re: URLs are state containers

#214

i see the complaints around URL length limits and i raise you.. storing the entire state in the hash component of the URL http://example.com/foo#abc since this is entirely client-side, you can pretty much bypass all of the limits. one place i've seen this used is the azure portal.. (payload | gzip | b64) take of that what you will.

Except you hit limits when trying to share that URL. Eg: try pasting a URL longer than 4096 bytes in Signal or WhatsApp, and they don't render it as clickable.

Re: URLs are state containers

#215
post #211

Earlier quoted context omitted.

Most desktops apps are buggy enough to occasionally require restarts or even crash. I don't currently use any program that never crashed on me. On the web "restarting the app" is seamless and not imply anything wrong happened. It's like the Erlang approach to errors, but on steroids The trouble with leaving restoring state to the application do as they wish is that most of times they will get it wrong. Also most of t…

My experience has been different – and increasingly so over the past 30 years. Crashing or leaking desktop apps are a rare experience nowadays. When it happens, it’s always an "oh, really?" moment. On the web… I often can’t even write a Facebook comment without refreshing the page. Good defaults definitely matter. But not overloading an app with functionality matters as well. Matching feature sets to actual user need…

I was just replying to someone on Messenger (the React Native app) and needed to paste a Unicode character via copy-paste. For some reason, the input field kept inserting it with a prepended space. I double- and triple-checked – copied it from different places – but nothing helped. It just kept adding that space. I ended up using the Drafts editor to write the full message and then pasted it into this crappy piece of software made by the very company that created the framework it’s built on. And the thing is, it’s not even surprising.

Re: URLs are state containers

#216

Earlier quoted context omitted.

It doesn't help that URLs are badly designed. It's a mix of left- and rightmost significant notation, so the most significant part is in the middle of the URL and hard to spot for someone non-technical. Really we should be going to com.ycombinator.news/item?id=45789474 instead.

I disagree. We write left to right, so it makes sense when the URL is essentially two parts ("external" and "internal" in regards to "place on the network", "location on the server") they are written left to right and then separated in the middle. Plus it would make using autocomplete way harder, since I can write "news.y" and get already suggested this site, or "red" and get reddit. If you were to change that, you'd…

But the domain name is not written "left to right", is the problem.

As far as autocomplete goes, what you're describing is a behavior of one particular implementation. If URLs looked differently, autocomplete would behave differently as well.

I'm also reminded of https://xkcd.com/1172/

Re: URLs are state containers

#217
> ?theme=dark&lang=en - UI preferences

Although the article is completely on point, I disagree that theme should be stored in URL.

Imagine you’re browsing a site, and at some point you switch from light to dark theme. After some time, you press “Back”. Do you really expect to switch back to light theme, and not to go to the previous page?

I've seen a lot of “well‑behaved” sites, that are storing their state in the URL, but I've never seen one, that stores current theme.

It’s interesting that the theme is part of the state too, yet you don’t want to store it in the URL. So, this means not every part of the state should be stored in the URL? Then what's the criteria for choosing what to store, and what not to?

Re: URLs are state containers

#218

Earlier quoted context omitted.

Nothing weird about it, you see people arguing right here whether a site should add a new history entry when a filter is set. Interacting with the URL from JS within the page load cycle is inherently complex. For what it's worth, I'd also argue that the right behavior here is to replace . But that of course also means that now the URL on the history stack for this particular view will always have the filter in it (as…

> But that of course also means that now the URL on the history stack for this particular view will always have the filter in it (as opposed to an initial visit without having touched anything). I would have one state for when the user first entered the page, and then the first time they modify a filter, add a 2nd state. From thereon, keep updating/replacing that state. This way if the user clicks into the page, and…

I agree, this would be a good approach.

Unless of course, you initially visited the page with a stateful URL.

Post reply on HN