News for hackers. Stuff that matters.
Re:Why I hate your Single Page App by trjordan on Thursday August 31, 2017 @12:24PM (#15141406)
Why I hate your classic HTML app:

- Every click is a full page load, and you still didn't manage to get caching right, so it takes 2 seconds to load.

- When I have multiple tabs open, your badges and notifications fall out of date, because you never poll for updates.

- If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it.

- You forgot to update the styles on that rarely-used page, and now it's got half the new CSS and half the old CSS and the point is the header runs halfway down the goddamn content in Times New Roman.

I get it, there are problems with SPAs. But this perfect land of one-page-per-link has real usability problems if it's not implemented properly, and there's a lot of maintenance overhead associated with a sprawling mass of transcluded templates. If we're going to criticize an architecture because it's easy to poorly implement, I don't think "ROCA" or whatever we're calling it has any meaningful benefits over SPAs in the general case.

Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @12:48PM (#15141641)
Since we're talking about poorly implemented features.

Why I hate your SPA:

- If I click on a link, I receive no indication that I actually clicked a link, then 2-10 seconds later the page abruptly loads. Sometimes the page doesn't load at all.

- I cannot tap and hold a link, wait a second for the pop-up menu, and open the link in a new tab because the link isn't actually a link. It's implemented in JavaScript.

- The back and forward buttons don't work as expected because either history isn't maintained or it's shoddy (scrolling should not be a history event).

- The refresh page button don't work as expected because it resets you to the beginning.

Re:Why I hate your Single Page App by imglorp on Thursday August 31, 2017 @12:54PM (#15141698)
I think the prime directive of all UI should be, "Ack UI inputs immediately, no matter what else is going on." Throw up a spinner, make something throb, change a status to "loading", anything. Don't just go off and attempt to do it and hope for timely response.
Re:Why I hate your Single Page App by chiefalchemist on Thursday August 31, 2017 @10:33PM (#15145696)
Why can't the browser do this? I mean, it's a universal function / feature, right? And ultimately, it's the browsers that's waiting, not to application per se. (Yeah, I okay. But you know what I mean).

I can't think of any good reason why the browsers can't help out with this UI / UX. Am I crazy?

Re:Why I hate your Single Page App by Skinney on Friday September 01, 2017 @09:28AM (#15148150)
Technically, in a SPA, the browser isn't waiting. Clicking the link just triggers a function call.
Re:Why I hate your Single Page App by chiefalchemist on Saturday September 09, 2017 @08:10PM (#15209767)
There has to be a wait somewhere. That is, the browser can't update anything until it knows what to do. So between the click and that new assignment is wait, yes?
Re:Why I hate your Single Page App by aaron-lebo on Thursday August 31, 2017 @12:54PM (#15141691)
Just to be clear, that is a poorly designed SPA, none of that should be happening and is easy to avoid.
Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @01:00PM (#15141766)
That is absolutely true, but I've seen it enough times to be annoyed. Also, the grand parent post was about classic HTML apps which were poorly designed with issues that should be easily avoidable.
Re:Why I hate your Single Page App by tarboreus on Thursday August 31, 2017 @04:01PM (#15143406)
A normal web page doesn't have to be well-designed in these ways, though. And SPAs often are not designed in this way. The author addresses this pretty well in the first paragraph.
Re:Why I hate your Single Page App by threatofrain on Thursday August 31, 2017 @01:17PM (#15141921)
When you click a link or button on a normal website, the browser doesn't give indication on the ongoing state of your http request either. Only a javascript-enhanced experience can do that.

Clicking on a save button and seeing the page hang is the normal way browsers handle http requests. But a javascript-enhanced experience can tell users about the local perception of the http request (ongoing, timeout, retry, error), or it can inform the user that it's safe to navigate away while their requests retry.

Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @01:48PM (#15142207)
Firefox for Android shows a thin orange progress bar beneath the navigation bar, and Chrome for Android shows a similar blue one. Firefox and Chrome for the desktop show the loading spinner in the tab.
Re:Why I hate your Single Page App by mikewhy on Thursday August 31, 2017 @01:25PM (#15141985)
Most browsers at least show a spinner somewhere, do they not?
Re:Why I hate your Single Page App by ge96 on Thursday August 31, 2017 @02:04PM (#15142370)
In chrome the bottom left status "connecting url..." Like a grey rectangle
Re:Why I hate your Single Page App by tarboreus on Thursday August 31, 2017 @04:00PM (#15143394)
Most indicate this by making the refresh button into an X or similar, and usually with one or two small visual indicators. Safari on iOS shows a little bar, etc.
Re:Why I hate your Single Page App by threatofrain on Thursday August 31, 2017 @01:44PM (#15142169)
Forgot about that one.
Re:Why I hate your Single Page App by ge96 on Thursday August 31, 2017 @02:03PM (#15142359)
I love browser push state so cool, but yeah if it doesn't work right you get stuck not being able to go back.

Edit: also agree to it disappear when accidentally hit back or leave page... I don't think you need to ask permission to use cookies so should opt for it... Or some other way to store.

Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @02:24PM (#15142551)
The problem with using cookies for navigation is then you restrict the user to a single window/tab. If the user opens a separate window and navigates somewhere else in the application, the cookie state will reflect the new window and disregard the state from the previous one.
Re:Why I hate your Single Page App by ge96 on Thursday August 31, 2017 @02:29PM (#15142604)
Sorry for the cookies I meant the storing of whatever you were writing into a form and accidentally hitting back or navigating away from the page. Like in mobile leaving the browser and returning to it, sometimes for me it starts it over haha no, just empty your soul into an essay response, all gone. Probably soared the recipient.

Interesting about the separate window, thought cookies could be set to never expire.

Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @02:55PM (#15142804)
Oh, I see. For saving the form state, localStorage would work better than cookies for saving and restoring because then the information is only kept on the client. That still doesn't solve the multiple window problem, but that's likely less of an issue for a filling out a form than for navigation.

Cookies can certainly be set to never expire, but you don't know which window the cookie was intended for because the cookies are shared.

Re:Why I hate your Single Page App by ge96 on Thursday August 31, 2017 @11:20PM (#15145866)
I wasn't aware. Are you talking like HTML5? Haven't used local storage before. Thanks for the info.
Re:Why I hate your Single Page App by cpburns2009 on Friday September 01, 2017 @08:14AM (#15147690)
Re:Why I hate your Single Page App by ge96 on Monday September 04, 2017 @03:27AM (#15166391)
thanks for the references, I'd like to start using it at some point. Would be cool to check the client's device capabilities/run a specific event based on conditions met.

I finally used memcache(d) so that's cool.

Re:Why I hate your Single Page App by anotherlurker on Thursday August 31, 2017 @01:15PM (#15141903)
Back and forward buttons should scroll when there is a link to an anchor on the same page.
Re:Why I hate your Single Page App by cpburns2009 on Thursday August 31, 2017 @01:45PM (#15142174)
There was some website linked to by HN a while ago that as you scrolled down the page, history events would be recorded. So if you wanted to go back to the previous page, you'd have to press back about 8 times if you scrolled to the end of the article.
Re:Why I hate your Single Page App by elpool2 on Thursday August 31, 2017 @02:37PM (#15142676)
Slate.com does this.
Re:Why I hate your Single Page App by romaniv on Thursday August 31, 2017 @01:14PM (#15141890)
. - If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it.

Funny that you mention it. Loosing form data on page refresh or clicking "back" button was a problem on the Web until browsers started keeping form state along with page history. Suddenly millions of websites got this new feature without actually doing anything differently. But that was only possible because page transfers were semantic. Frameworks of that time that tried to manage their own form state (like ASP.NET WebForms) didn't have real page transfers, so they didn't get this "upgrade" and currently are significantly worse off in terms of usability.

I think there is a lesson here.

Re:Why I hate your Single Page App by tjoff on Thursday August 31, 2017 @12:47PM (#15141617)
You probably have never tried a classic HTML "app":

1. Every click is fetched and rendered faster than your javascript code has had a chance to execute, let alone fetch or render.

2. True, minor headache though compared to the vast improvements in usability.

3. Nope.

4. Nope, this is a bug - something javascript pages most certainly are not immune against.

Re:Why I hate your Single Page App by philosopherlawr on Thursday August 31, 2017 @12:54PM (#15141697)
You're basing a lot of this viewpoint on fast internet connections. Javascript code rendering will be faster if you have a slow internet connection and are using an updated browser with a fast javascript engine
Re:Why I hate your Single Page App by e12e on Thursday August 31, 2017 @01:38PM (#15142093)
Eh, I've yet to experience an spa that feels or is faster than the equivalent simple html, no matter what network I'm on - with the exception of being off-line (and I've seen few enough spas that actually work better offline than static pages, ie not broken navigation/functionality).

Note that I've of course seen countless slow, bloated static pages - but that's pretty much never because of the tech stack - but because of bloated css, silly large images, and often horrible convoluted html.

Hn is of course a typical example of a web page that on paper would be great as an spa, but works fine as a static page with minor js (broken up/down links notwithstanding..).

D-lang forums is another :

https://forum.dlang.org/

Assuming a 64 kbps connection, and a 50%+ gzip compression, downloading a couple of pages of text is done in about half a second. If the user has such a terrible connection, they've hopefully turned off image loading. I don't think adding 40-400 kbs of gzipped js is going to help with the speed...

https://gist.github.com/Restuta/cda69e50a853aa64912d

Re:Why I hate your Single Page App by Skinney on Friday September 01, 2017 @09:34AM (#15148178)
How do you know when you're using a SPA and when you're not? Seems to me, a well designed SPA is indistinguishable from a regular HTML site unless you're actively looking at the network tab. Could it be that you have a bad impression of SPAs, because you only really notice it when you're using a badly designed one?
Re:Why I hate your Single Page App by slavik81 on Thursday August 31, 2017 @01:50PM (#15142236)
One nice thing about regular HTML websites is that they only need to be downloaded once. When I was taking the train in to school, I'd often have a bunch of tabs open on my phone. If I tried to switch to an old Reddit (SPA) tab while going through a tunnel, the page would try to reload, fail, and replace all the content that was already there with an error message. With HN, by contrast, I could open up a bunch of tabs while I still had good internet and switch to them later even when I didn't.
Re:Why I hate your Single Page App by tjoff on Thursday August 31, 2017 @12:58PM (#15141730)
In theory you have a point. In practice though the initial loading of the first page is so slow that it completely negates the benefits entirely.

It also doesn't work well when opening lots of tabs (which is a popular technique that helps immensely when browsing on a slow connection as pages are loaded in the background).

And if you have a really slow or spotty connection the javascript page would barely load at all.

Re:Why I hate your Single Page App by philosopherlawr on Thursday August 31, 2017 @01:25PM (#15141987)
I think you're basing this off of old technology. With webpack 2 and HTTP/2, this is less of an issue. But, the top comment's statement I think is the most valid: if you're loading static text, then simple html pages are the best. Notice the rise in popularity of static site generators for this purpose. A SPA will win out when you have lots of interactions and you only experience the initial loading of the first page once - and then the majority of your user experience is around interacting with the app.
Re:Why I hate your Single Page App by lousken on Thursday August 31, 2017 @07:02PM (#15144723)
From time to time I have to use 64kbps on my cellphone. At that point the biggest pain in the ass becomes first loading and in that classic HTML app shines, it loads a LOT faster - if you have 1.5MB page or 600kB makes a huge difference. But once it's all static content is cached it pretty much doesn't matter if it's XHR or full page load since I'm loading only tens of kBs at max.

Also if I have to use 64kb I completly disable js in my browser and whitelist just a couple of websites - best adblock on mobile.

Re:Why I hate your Single Page App by jasonjei on Thursday August 31, 2017 @01:48PM (#15142214)
I actually prefer HTML over SPA apps on slower Internet connections. I've found SPAs to be more infuriating to use when the connection is bad.
Re:Why I hate your Single Page App by flukus on Thursday August 31, 2017 @11:27PM (#15145895)
Designing with intermittent connections in mind is a lost art, even the windows 10 start menu won't work properly with one.

Unfortunately connection are more intermittent now than ever before.

Re:Why I hate your Single Page App by tscs37 on Thursday August 31, 2017 @01:46PM (#15142185)
My homepage has about 81kb of data to transfer, including images.

If you turn off images, you get in with 12kb of data. I think 12kb of data should be transferred faster than even the more lighter JS frameworks around...

Re:Why I hate your Single Page App by howlgram on Sunday September 03, 2017 @05:08AM (#15160421)
i much rather see my html page slowly loading before me than a js button that doesn't load and when i decide that it's taking too long and i want to go back then everything just messes up because it doesn't work with the back button in the browser
Re:Why I hate your Single Page App by trjordan on Thursday August 31, 2017 @01:10PM (#15141860)
Of course I've tried a classic HTML app. That seems disingenuous?
Re:Why I hate your Single Page App by smhenderson on Thursday August 31, 2017 @12:43PM (#15141589)
- If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it.

Even when I was coding web pages in Perl in the 90's I wouldn't do that to a user, that's just mean. You don't need a SPA to provide proper error handling that also rebuilds previous state.

Re:Why I hate your Single Page App by sireat on Thursday August 31, 2017 @01:13PM (#15141883)
Sadly there is a major e-commerce provider in my niche which does exactly that - routinely forgets all my information.

In fact sometimes their web form just forgets things for no reason.

There is no competitor in sight because of the huge huge SEO juice they have built over 15 years.

Re:Why I hate your Single Page App by smhenderson on Thursday August 31, 2017 @04:29PM (#15143648)
Oh, I know, I have a few examples as well, mostly regarding paying bills. Hate those sites but what can I do? I guess I could go back to mailing a check :-)

But it's not THAT inconvenient!

Re:Why I hate your Single Page App by darkstar999 on Thursday August 31, 2017 @12:31PM (#15141461)
Most of your criticisms are solved with basic javascript, not necessarily single page applications.

> You forgot to update the styles on that rarely-used page

That's solved with proper css, not SPA.

Re:Why I hate your Single Page App by trjordan on Thursday August 31, 2017 @01:08PM (#15141845)
You're right! If we just implemented everything correctly, there wouldn't be problems!

Anecdotally, every team I've worked with has converted to a SPA, and the main ergonomic upgrade is that updates to the signup page or the "not found" widget quit getting forgotten whenever we change tweak our design. There always seems to be one page that's out-of-date for 2 months before anybody notices, then it quietly gets fixed up because we forgot that the design tweak was a CSS+HTML change, not pure CSS.

Not that that's perfect -- once you have a SPA, nobody remembers the 404 page, because it's a different HTML base...

Re:Why I hate your Single Page App by jfaat on Thursday August 31, 2017 @12:35PM (#15141498)
Also a sane build/deployment process will solve this.
Re:Why I hate your Single Page App by romaniv on Thursday August 31, 2017 @01:04PM (#15141797)
. - If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it.

This was fixed in browsers years ago when they started keeping form state along with page history. I can refresh this page, go back and forth in history, and this text box will keep my comment. Ironically, websites that tried to be clever about form state management and faked page transfers (like ASP.NET WebForms) didn't benefit from the fixes and currently are significantly worse off in terms of usability than websites that used vanilla forms.

I think there is a lesson here.

Re:Why I hate your Single Page App by yellowapple on Thursday August 31, 2017 @12:52PM (#15141674)
"[each click] takes 2 seconds to load"

In about 95% of the SPAs I've tried, each click takes even longer than that.

"you never poll for updates"

Yes, because apparently AJAX/AJAJ is completely nonexistent and there's absolutely zero ground between "pure-HTML like it's 1991" and "VueWangulaReact.js single-page monstrosity".

Hell, even a meta-refresh will fix that if you really do want "pure-HTML like it's 1991", though that's certainly inelegant.

Re:Why I hate your Single Page App by ojosilva on Thursday August 31, 2017 @12:41PM (#15141558)
Exactly.

- The author is describing hypertext, which is perfectly fine for textual static content, one of the key goals for which the World Wide Web was conceived.

- Server-side generation of HTML seems totally out of place for other use cases: HTML/JS are now the assembly languages of the web and they belong in the browser. Besides a more distributed architecture is just perfect: server and client focus on what they do best.

- Fixing web-apps with broken history buttons and unlinkable urls is important, but to be honest there are fewer and fewer SPAs that are mono-url these days. And it's perfectly fine to have a unlinkable "Delete this Invoice" app button. If it's not real content it should not be a link.

Re:Why I hate your Single Page App by s17n on Thursday August 31, 2017 @01:16PM (#15141909)
The last bullet is just a straight up error on the part of the developer. The third... isn't real? What browser doesn't save form state?

The first two are fair criticism but they aren't nearly as detrimental to the user experience as the typical single page app antipatterns (no history, no indication of page loading, refresh button is broken, etc).

While it is of course possible to execute any design well or poorly, the observation that a typical single page app is worse than a typical multipage app is certainly valid.

Re:Why I hate your Single Page App by lscharen on Thursday August 31, 2017 @12:31PM (#15141457)
"If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it."

This. I have a very short list of architectural must-haves that I use when evaluating junior dev's code at the start of a project, and not having robust error handling that preserves submitted form information is right up near the top.

It's an annoying design mistake with two input elements, unworkable with five, and just plain cruel beyond that.

Re:Why I hate your Single Page App by ruleabidinguser on Thursday August 31, 2017 @12:35PM (#15141501)
You're not evaluating them based on requirements you didn't share, are you? That seems a little unfair
Re:Why I hate your Single Page App by lscharen on Thursday August 31, 2017 @12:58PM (#15141732)
Not evaluating them; evaluating code.

Just handing someone an expanded version of "implement good error handling" is not likely to result in a good product. Every project has nuance and subtle trade-offs -- the code review is an opportunity to teach juniors how to map abstract design principles onto concrete implementations without falling back to "cookbook / cargo cult" programming.

I want them to take ownership of their own code, and advance down the path of craftsmanship because I believe this results in long-term value -- both to them personally and to the project at hand.

Re:Why I hate your Single Page App by Xoros on Thursday August 31, 2017 @12:57PM (#15141728)
Is'nt that the point of an evaluation ?

"Hey, here is your test and here are the answers. You've got one hour" :)

Re:Why I hate your Single Page App by ruleabidinguser on Sunday September 03, 2017 @05:54PM (#15164151)
Not really no
Re:Why I hate your Single Page App by Pigo on Thursday August 31, 2017 @12:35PM (#15141504)
I only scanned towards the end, but I was waiting to here what his proper architectural would be. I don't like complaining unless you have alternative you're ready to support.
Re:Why I hate your Single Page App by mikestew on Thursday August 31, 2017 @12:41PM (#15141555)
From TFA: "What is this alternative, then? It is to build a classic web application, including rendering server-side HTML, and use JavaScript only sparingly, to enhance browser functionality where possible."
Re:Why I hate your Single Page App by mnarayan01 on Thursday August 31, 2017 @12:44PM (#15141595)
> If I mis-enter information into a form, your error handling forgets all my information and I have to re-enter it.

This really shouldn't be a problem for anything other than file inputs. If someone's form is losing submitted information on a validation failure when using an actual HTML submit, then I find it pretty unlikely that they're doing a good job of AJAX submission.

Re:Why I hate your Single Page App by amelius on Thursday August 31, 2017 @12:40PM (#15141544)
> When I have multiple tabs open, your badges and notifications fall out of date, because you never poll for updates.

How bad is that really if users are aware of it and they can simply reload the page?

Re:Why I hate your Single Page App by williamdclt on Thursday August 31, 2017 @12:55PM (#15141715)
Not very bad for Hackernews. Terrible for Facebook, Twitter or any website that claims to be interactive
Re:Why I hate your Single Page App by amelius on Thursday August 31, 2017 @01:25PM (#15141986)
Personally, I'm not eagerly waiting for updates on Facebook all the time. They might as well appear after a reload.

Of course, chat/messenger is something else, but I consider that an exception. (It's easy to build a chat service on top of a static website).