matb33.me

Mathieu Bouchard

Writing web apps through thick and thin

In my humble opinion, modern web apps should be Thick Clients driven by Hypermedia APIs.

But this may not be the right choice at this point, depending on your choice of technology stack.

I have to admit, the framework landscape currently out there isn't very conducive to the Thick Client backed by the Hypermedia API. If you need something done fast, you could use something like Ruby on Rails to put your web application together quickly.

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.

Advantages:

  1. Conventional, well-understood, documented, stable... (get something up fast)

Disadvantages:

  1. Data re-usability difficult (extra work to achieve an API).
  2. 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.

Advantages:

  1. Clean separation of concerns
  2. API is used for app and can be accessed programmatically (two birds with one stone)
  3. New front-end can be written for different audiences (native apps for example) at lesser cost (same API)

Disadvantages:

  1. 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.