5 ms·
Hmm, degraded development experience of doing everything on the client? Bit of a bizarre claim there given the state of templating these days. Sounds more of a
by mattmanser 15y ago
Hmm, degraded development experience of doing everything on the client?
Bit of a bizarre claim there given the state of templating these days. Sounds more of a prejudice than an actual problem.
Also json tends to be much lighter than HTML and if you're taking an optimistic view of updates you can assume the action's been a success and even immediately update the display without waiting for the server to create some simple HTML, so it's arguably a worse user experience due to the lag.
- dhh 15y agoWe've found that the additional overhead of sending HTML vs JSON is negligible in most cases. The additional speed gained by just sending JSON across is not worth the programming enjoyment hit of doing everything client-side. When you get below 50-100ms per action, things are generally fast enough that this is not a key problem any more. The user cares greatly if you can go from 800ms to 100ms, but not so much if you can go from 100ms to 70ms.
- MatthewPhillips 15y agoProgramming enjoyment is, of course, subjective, but for your team the enjoyment is ruby, understood :) What browsers are you getting the 50-100ms numbers? Similar results on mobile (with a 3G connection)?
- dhh 15y ago50-100ms is the time it takes to generate the response on the server. On top of that you have to add the ping time between you and server and whatever other network overhead there is. That's why it's great to be closer to 50ms so you'll stay under 100ms even with the network overhead.
- ayanb 15y agoHow does this impact if you are aiming to build a JSON API too?
- MatthewPhillips 15y agoDouble work.
- brunoc 15y agoNot with Rails, afaik. Assuming the routes are consistent, you simply add a 'respond' for JSON and send the relevant chunk of the model. Easy as pie.
- nkohari 15y agoThat assumes, of course, that the viewmodel used to render the server-side view is identical to the model you'd return serialized into JSON. That's mostly true, but not always.
- zaidf 15y agoI have to agree here. A major problem with client-side json is the need for additional documentation and likelihood of things breaking because of simple html edits. For example, if you are populating a bunch of divs inside a parent div with the data returned using json, you would describe this using something like jquery selectors. Now if someone else comes and moves around the div during a redesign, he must go through whole bunch of js to make sure his shuffling of the divs around won't break the jquery selectors populating the data from json. Now think about having a parent div that is simply populated with returned HTML from server-side and it seems way easier than using json to populate the data.
- jonknee 15y agoThat's nonsense, the same issue would apply on the server side templates. If you go around messing with DIVs without an idea of the consequences, you will get in trouble regardless of your templates being on the server or client. If you try to have the designer do a redesign without testing the application afterwards, you're always in for trouble.
- zaidf 15y agoyou will get in trouble regardless of your templates being on the server or client My view is that you will get in significantly less trouble because manipulating an HTML template that is rendered on server side is much easier to manage and adapt to a new design than finding nitpick jquery selectors across the app that depend on a specific div structure. Btw, my post doesn't imply anywhere that a designer should redesign an app without testing. Therefore, your argument about testing is garbage.
- agilebyte 15y agoRather than "finding nitpick jquery selectors" I use a client side framework (backbone.js) with a lot of Views which makes my development faster vs using server side templating, so I cannot share your opinion.
- cicloid 15y agoHow about HTML versus MessagePack ( http://msgpack.org/ http://msgpack.org/ )?
- condiment 15y agoYour comment ignores the next section in the article, detailing how they are caching templates with a high level of granularity, and actively removing template logic that impedes efficient cacheing. The article goes on to state that delivery times for cached segments of HTML are under 50ms in most cases. While I agree that it would be possible for them to improve the user's perception of the app performance even further via JSON or client-side updates, with the level of performance they described that type of improvement is unnecessary and introduces additional vectors for bugs to creep into production code.
- MatthewPhillips 15y agoStacker sounds like AJAX as it was done in 2006, except trigger by pushState. Maybe I'm misunderstanding it though. I'd be curious what the performance penalty is on mobile.
- latch 15y agoWell, it's really stacker + pushState + MAX cache. But why would there be a performance penalty? Doesn't this result in the client doing _less_ work all around? Less work than the multi-page approach...and less work from the client-side templating approach, no?
- asaeidi 15y agoSeems it's a highly refined version of what was done in the "old" days. I remember doing something similar for an old project in ASP.NET. (Well more similar to pjax) As to performance on mobile, i think it might all depend on how large the html fragments are.
- jd 15y agoWhen you have a persistent page (that you update with HTML5 push-state) you suddenly have to worry about issues like memory fragmentation. If you do lots of small updates to build a page from a template + JSON every time the user navigates it's easy to hit some situation where everything starts lagging for no clear reason. If you simply swap out a large part of the page with some HTML right out of an Ajax request you don't have to worry about any of that.
- arturadib 15y agoLet's be fair - poorly designed code causes memory bloat whether you're on the client or on the server-side. Also, garbage collection efficiency in browsers is a metric of fierce competition among browsers. It's superb already, and it's getting awesomer by the minute. It's a safe choice for the future.
- Joeri 15y agoAnd when you do everything client-side, you have to worry about memory leaks. Where the state is, is where the memory pain is.
- arturadib 15y agoExactly what I thought. But you have to remember that 37 is the quintessential Rails shop - client-side logic is not their sweet spot. So it's only natural that for their flagship product they'd rather keep pushing the limits of their comfort zone rather than go all out client-side, no matter how natural that choice might be for a "web app".
- jondot 15y agoWith all of the backbone and node.js hype going around, people tend to forget that client-side development is developing on the client's side. Sooner than later you will have to deal with * nondeterministic testing, * interactive testing (leaving machines on to run interactive testing at night), * most of the bugs will live on the client side, * you'll have to support each and every machine's quirks (you can't pretend everyone are on at least core i5 and chrome, people WILL have machines that do javascript client side template rendering SLOWLY). * you'll have to find ways to diagnose problems at the client's site, and you will maintain a fleet of various computer configurations to run sanity on. * which will also cause you to start investing in pairwise testing * i can go on DHH is COMPLETELY right. Just because the universe is not ready enough for client side "SPA"s (universe=browsers,internet) I'm laying my arguments out of experience - I've been a long time Ruby/Rails/.Net/JVM server side dev as well as enterprise software dev (enterprise desktop/workstation application suites, as complex as visual studio and the sorts). I have several node.js projects in production and I'm also doing a couple of projects with Backbone.
- boucher 15y agoYour arguments are a checklist of responsibilities for anyone running any web software, whether the actual DOM elements are being rendered on the server or the client.
- jondot 15y agoI agree that you do most of these arguments when most of your content render on the servers too. However, you DO have limited resources (time, money, people), and these points become more and more painful as you push towards client side. Still, I insist that some of these arguments are client side specific. Once instance is javascript template rendering speed. Another is, that you would prefer getting statistics on your speed of rendering at the server's side where it is easily controllable and deterministic, rather than shuffle around to close that loop and build a usage service to report back usage and statistics to from the client's side. I give my arguments from pain and experience in both sides, and I still do both sides despite of the arguments (since it is not always my own choice).