SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)

    Client-side mvc vs Server-side rails views

    There's a really interesting video with @dhh talking about his thoughts on client-side MVC frameworks with Rails.
    www.youtube.com/watch?v=FkLVl3gpJP4

    He goes into some detail about Pjax and 37signals caching strategy so that partial page updates are snappy and that gives you an experience much like the client-side frameworks without the added complexity.

    After working with Backbone.js for a while now I agree with him that development experience of client-side views isn't nearly as nice as generating the views from rails.

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,329
    Mentioned
    191 Post(s)
    Tagged
    4 Thread(s)
    Cool stuff. Thanks for sharing this.
    @DHH is a really smart guy and he has a nice (relaxed) presentation style; I have seen him a few times at conferences.
    I have not had time to take a look at Backbone.js but it seems to be "coming up in conversation" quite a lot lately. I am very curious. How would you characterize it in "an elevator speech"?
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    The intro on the site is pretty succinct.

    Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

    It gives you models which you can fetch, destroy, update, delete over a JSON api.
    A router for updating the URL's with pushState when navigating around different "pages" client-side.
    View classes for you to put your event bindings.

    It's all driven by a nice set of events, e.g. when data changes in your models you can respond to them.

    It's pretty nice and is popular but there's a lot of other frameworks like Ember.js and Angular.js which are also becoming popular.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You really wouldn't use backbone.js within a rails app -- it is meant for pure JS apps where there isn't as much server-side framework to hang off of. It solves a different problem than rails.

    The huge disadvantage of rendering partial views and returning them down to the client is larger payload going down the wire and increased server load from rendering templates.

  5. #5
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    You really wouldn't use backbone.js within a rails app -- it is meant for pure JS apps where there isn't as much server-side framework to hang off of. It solves a different problem than rails.
    Backbone actually works really well with Rails. It is great for building json api's and routing, controllers, models, db migrations, validations etc.. are all just as relevant - it's only the views that change with Backbone.
    Quote Originally Posted by Jeremy Ashkenas
    You're in luck! Backbone was originally developed to work with a Rails app, so things should be as seamless as possible.
    dhh is arguing that you shouldn't build your entire application client-side, and I agree with him. I prefer to keep client-side complexity for those parts of the app that will really benefit from it. And backbone works well here, able to be used in some parts of your application but not all.
    Quote Originally Posted by wwb_99 View Post
    The huge disadvantage of rendering partial views and returning them down to the client is larger payload going down the wire and increased server load from rendering templates.
    Did you watch the video?
    This turns out to be not such a "huge disadvantage" as you think, the speed difference really is negligible. After all, we've been developing applications with full page refreshes for a long time now. PJax is the simplest way to get an big speed boost without changing a lot. Sending HTML is not a disadvantage.

    As I see it there's far more disadvantages to doing this 100% on the client, a few benefits of doing this on the server are:
    - It's far less complex, that's #1 for me
    - You're sending a lot less js at the start
    - You're waiting for less things to initialize on the client
    - You can use all of the server-side tools you're used to
    - Pjax and Caching makes this just as responsive, for the most part.
    - It's faster to develop
    - Easier to test
    - Fewer bugs
    - Easier to make accessible
    - SEO friendly


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •