Blog

the writings of

The Javascript Stack

January 18, 2012

The future of web development is likely to be a full javascript-driven stack, from servers through templates.

If you're interested in JavaScript or web app design/development, take a minute to read Luke's article on the subject.

I noticed this a few months ago as well. I'm glad I'm not crazy. I take Wroblewski's word as some sort of validation.

At any rate, taken one step further, there are templating engines that work in JavaScript using JSON as well:

So, now you can have a database that stores JSON, a JavaScript server/framework that retrieves that JSON, and a template language that accepts and parses JSON. And, client machines can handle all that parsing just about as well as the server.

Where I think this has some great implications is in AJAX-driven web apps. A lot of the power here comes from being able to pass around JSON and have it handled both client-side and server-side.

A common thing I run into in my web work is in deciding how to respond to AJAX requests when a significant portion of markup needs to be replaced after the response is sent back. The first choice is so ship some JSON to the browser and let some JavaScript on the user's end turn it into markup. The second option is to massage the data on the server and then use whatever templating engine is being used by the app to mark it up, then ship that HTML to the user.

The first option tends to be cleaner and better separates the server/client relationship. However, the power of the app's template system is lost (assuming one is being used). Also, your less DRY in your development, as you have templating going on in two places and if you make a change to the layout, you need to make it in two places. The second option regains the consistency of using just one template engine (plus all the other good server-side processing bits) but seems to tie the server up in presentation, which perhaps would be better suited as a client-side job for better separation of duties. Plus, shipping markup back and forth tends to be less efficient than transmitting raw JSON.

Enter the "JavaScript Stack" and the template engines listed above. With a full JavaScript stack, one could use a template engine on the server, then package that engine up and ship it off to the client for use there as well, because the client can already use the language. It's just Javascript, after all.

In this case, you can just pass JSON back and forth during AJAX requests and you have a full stack that understands how to work with it in a consistent manner.

blog comments powered by Disqus