DHH claimed that the development experience of client-side MVC is inferior compared to traditional Rails development. And he only gave two vague reasons - ruby and 'unnecessary' complexity. his article first shows some code comparison between the two paradigms to demonstrate the software design drive for client-side MV* and then talks about the business drive for client-side MVC(*) - interactivity.
[+] [-] olegp|13 years ago|reply
I myself have been working on https://starthq.com which started life as a single page app using AngularJS where most of the functionality was behind a login. It has now pivoted into a web app directory, where delivering the initial page quickly and in a way that Google can easily index is crucial & there's very little actual input validation or interactivity on the page. The nice thing is that despite this transition, the core API has remained the same regardless of where the view is rendered and the architecture is all the better for it.
Give it a go and see if you can tell which pages are rendered entirely on the server and which entirely on the client.
[+] [-] Joeri|13 years ago|reply
I work on a 400 kloc app developed with a client-side mvc + web services architecture. The nice thing I've learnt about having a proper services api is that slapping another front-end on top of it is straightforward. We've had a relatively easy time building mobile apps thanks to having the service api ready. And because the core app is built around the same services, they are less likely to break.
[+] [-] qschneier|13 years ago|reply
[+] [-] wildmusings|13 years ago|reply
When you do client-side MVC, you end up having to duplicate a lot of your model and controller logic. This happens either explicitly, when you start defining relationships between models and how they should react to changes in associated models (e.g. backbone-relational), or implicitly, when it gets stuffed into view and "routing" logic (and leaving you with spaghetti code that's different but no better than jquery spaghetti). In rails views, you have access to the real model objects and you can still use AJAX to have a "single-page application" without the huge added complexity.
There's obviously a place for client-side MVC and that is RICH APPLICATIONS. Google Docs, Pandora, a photo editor, etc...
I think another factor is what your team looks like. If the person writing the models and controllers is the same guy making the front end, then you should probably stay away from client-side MVC. If you have dedicated frontend/javascript guys, then it might make more sense..
[+] [-] kailuowang|13 years ago|reply
[+] [-] lucaspiller|13 years ago|reply
I don't think either solution is really that great at the moment. Doing things MV* client side mean you duplicate views and potentially logic (we use decorators a lot which would need to be duplicated). Doing things via AJAX means you have to wait for the response before the view is updated (things like comments that will succeed - assuming validations are done before the request is made, and the server doesn't break - shouldn't have this delay).
One thing we have done that has helped, is instead of just attaching a load of jQuery events on random elements, is writing our Javascript in a similar style to Backbone views. Instead of writing everything with lots of nested events, we have a 'controller' responsible for each feature. On initialisation it binds to the DOM events it needs, and those call other methods on the controller. It also has it's own (local) state, so if we need to use the same feature multiple times on a page we can do with ease. It has allowed us to separate code better, and more importantly make it more legible. Here is an example:
https://gist.github.com/lucaspiller/5040983
[+] [-] amikazmi|13 years ago|reply
[+] [-] smidwap|13 years ago|reply
2. A huge aspect of choosing Rails or client-side MVC is productivity. If you're going to build a web app in Ruby, you're going to have to have somebody on your team that is good at Ruby. By layering a client-side MVC on top of that, you're now requiring javascript expertise. Your life is now twice as difficult.
3. It's amazing how powerful DHH's approach is. Just look at the new Basecamp. Does any part of that app feel slow, clumsy, and non-interactive? Absolutely not. I imagine myself being opening up the Basecamp codebase and "getting it" within a day. If you understand your constraints well, you can deliver amazing software with an order of magnitude less complexity.
[+] [-] SkyMarshal|13 years ago|reply
Even with FB and Gmail, I've gotten the impression that neither of those is fully client or server-side, but rather highly optimized hybrids where component processing tasks are done wherever they can be with highest performance and lowest latency.
Both seem acutely conscious of comparative speeds of server-side rendering + internet latency vs. client-side rendering.
Not sure though, only an impression based on anecdotal evidence, anyone more familiar with their architectures?
[+] [-] srid68|13 years ago|reply
I have found that increasing the DOM element count leads to poor performance, hence too much view template loaded initially leads to unnecessary slowness. To mitigate this i started dynamic loading of view templates from the server, which lead to two different calls to the server, one to retrieve the json data and the other to retrieve the view template which makes some sense in certain use cases and sometime merging the data with the template makes it more performant and some case retrieving the template and data in a single call, but without merging is optimum. It all depends on the functionality required.
When you work in Old Android (Browser/WebView) devices, you will observe that using client side rendering and loading too much in the DOM leads to poor performance and it is better to render it on the server side and just use plain JavaScript to inject the rendered view to DOM, which leads to optimum performance.
[+] [-] dougk16|13 years ago|reply
That said, server-side rendering is a product of historical inertia. Remember, client-side MVC is the way things were quite successfully done before the internets came along. However, browsers originally sucked at anything "client", so we developed languages and design patterns and libraries that slowly made the concept of a server-generated view tolerable, to the point where many sites (e.g. HN or Wikipedia) are actually better served by doing everything on the server. Now that javascript is powerful enough though (and we can cross-compile from languages better suited to complex application development), client-side MVC is unsurprisingly making a comeback.
[+] [-] mckoss|13 years ago|reply
[+] [-] beermann|13 years ago|reply
This doesn't necessarily mean that you can't still do server-side views if you wanted to. But by separating the view rendering from the service layer you provide a bit more flexibility. Designed correctly, the argument becomes moot. Either you're creating a controller, models, and event callbacks on the server, or you're creating them on the client. Client-side javascript frameworks are getting so much better that it really just comes down to finding the best tools for your team.
[+] [-] Kiro|13 years ago|reply
[+] [-] orthecreedence|13 years ago|reply
I love this method because you can provide really snappy front-end experiences. It's also nice to focus on having a good solid API along with a consistent front-end, whereas splitting up your front-end between the server and the client can be more complicated than just doing it all in the client. Browsers are now capable to run the entire front-end, so why not let them?
[+] [-] udfalkso|13 years ago|reply
Here's a short primer: http://www.gethifi.com/blog/javascript-templates-and-how-we-...
There are various libraries you can use to make this easier for yourself. Underscore and handlebars are too good options.
[+] [-] programminggeek|13 years ago|reply
For example, if you want Google to crawl your stuff, go server side.
I think it's smart to look at it on a per-page or per app basis. Not everything should be client side MVC and not everything should be server side.
Do the right thing for your product.
[+] [-] orthecreedence|13 years ago|reply
[+] [-] ymn_ayk|13 years ago|reply
[+] [-] kaoD|13 years ago|reply
My bet would be both, but I couldn't find any framework that could render both server and client side templates based on the HTTP headers without enormous amounts of glue code.
[+] [-] beermann|13 years ago|reply
[+] [-] combataircraft|13 years ago|reply
[+] [-] rozap|13 years ago|reply
[+] [-] thibaut_barrere|13 years ago|reply
For more UI-dynamic apps like https://www.wisecashhq.com, I go Rails JSON back-end + html rendering for skeleton, and KnockOut.js for the interactivity.
Now that DHH advocates "his way or the highway" isn't really a surprise :-)
[+] [-] jbigelow76|13 years ago|reply
Maybe I'm just splitting hairs, in general I agree with the author's premise.
[+] [-] meaty|13 years ago|reply
[+] [-] shimms|13 years ago|reply
Or are you saying that it isn't possible to efficiently manage 2500 views using a client side framework?
[+] [-] edwinyzh|13 years ago|reply
Server-side views are good for content-oriented websites, while client-side MVC's are good for function-oriented webapps that needs clean architecture.
PS, I like AngularJS as the client-side MVC framework, and I'm trying to find a way to better support it in my current project (http://liveditor.com).
[+] [-] trungonnews|13 years ago|reply
[+] [-] papsosouid|13 years ago|reply
Yes, it is. 90% of the client side javascript interfaces I've seen provide absolutely no benefit to the user, and often are outright worse than a normal html interface (twitter). Your complaints about RoR's terrible templates do not generalize to all server side template engines, so the whole thing should be framed accurately as a comparison of your preferred javascript mvc framework vs rails templates.
[+] [-] nateabele|13 years ago|reply
Yes, strictly speaking, there's nothing inherent to client-side JS MVC frameworks that creates a better experience for end-users (over traditional server-side MVC + client-side Ajax + DOM manipulation, or whatever).
Where they do provide benefit is to developers, for whom it makes creating rich interfaces absurdly easy. Again, to be clear, this does nothing for users. Unless, of course, you consider that reduced barriers to implementing rich interactivity induce developers to use it create better user experiences, and that purpose-specific tools reduce the surface area for experience-disrupting bugs (which, statistically, you'd have more of, since you're operating at a lower level of abstraction and having to constantly repeat yourself [unless, of course, you decided to generalize all your Ajax & DOM manipulation and wrote a framework... oh wait]).
But hey, don't let me keep you from thinking whatever keeps you inside your comfort zone.
(Disclosure: the foregoing is based on ~1 year of experience developing applications with AngularJS).
[+] [-] bluetidepro|13 years ago|reply
[+] [-] timrpeterson|13 years ago|reply
[deleted]