Writing web apps through thick and thin
But this may not be the right choice at this point, depending on your choice of technology stack.
How does it stack up?
Stack choice #1: The Conventional Stack
- MVC on the server (RoR, Symfony2, and many many more) Heavy role, drives everything including front-end markup. Increasingly being dubbed as Spaghetti Rails (or Spaghetti PHP... enumerate and take your pick).
- JS framework, doesn't need to be MVC (jQuery, etc) Minimal if not zero functional role, mostly aesthetic with AJAX used to enhance user experience, sometimes almost as an after-thought.
- Conventional, well-understood, documented, stable... (get something up fast)
- Data re-usability difficult (extra work to achieve an API).
- Pigeon-holed into a particular audience, i.e. HTML for web
Stack choice #2: The Modern Stack
- API on the server (grape, but the other heavier frameworks can still do the job (RoR etc)) All the magic happens behind closed doors (data persistence, sessions, sending emails, etc) and the API is the gatekeeper.
- MVC on the client (Backbone, KnockoutJS, etc) The interface is written here, backed by the API. Essentially the client handles the front-end (views) entirely.
- Clean separation of concerns
- API is used for app and can be accessed programmatically (two birds with one stone)
- New front-end can be written for different audiences (native apps for example) at lesser cost (same API)
- Currently no complete frameworks to get this stack up and running as fast as the convential approach
- Front-end frameworks are still in their infancy (Backbone.js docs still tell you to bootstrap data... this practice forces your API to be aware of views)
- Back-end frameworks designed to output HTML views. This ripples out and affects the design and use cases of libraries built around these frameworks.
Which stack do I choose then?
Choose the Conventional Stack if you need something up very fast (prototype or deadline), or if your team/client want an established stack with lots of documentation and history. Expect a rewrite in the years to come, down to the architectural level.
Choose the Modern Stack if you are your own boss (side-project, cutting-edge CTO, etc) and can help build up this end of the spectrum with examples, frameworks and community! Expect rewriting only superficial code--your architecture will be sound.