Node.js and the JavaScript Age
2013-07-10 12:11
330 查看
Three months ago, we decided to tear down the framework we were using for our dashboard, Python’s Django, and rebuild it entirely in server-side JavaScript, using node.js. (If there is ever a time in a start-ups life to remodel parts of your infrastructure,
it’s early on, when your range of motion is highest.)
This decision was driven by a realization: the LAMP stack is dead. In the two decades since its birth, there have been fundamental shifts in the web’s make-up of content, protocols, servers, and clients. Together, these mark three ages of the web:
I. 1991-1999: The HTML Age.
The HTML Age was about documents, true to Tim Berners-Lee’s original vision of a “big, virtual documentation system in the sky.” The web was dominated by static, hand-coded files, which web clients crudely formatted (with defaults that offend even
the mildest of typographiles). Static documents were served to static clients.
II. 2000-2009: The LAMP Age.
The LAMP Age was about databases. Rather than documents, the dominant web stacks were LAMP or LAMP-like. Whether CGI, PHP, Ruby on Rails, or Django, the dominant pattern was populating an HTML template with database values. Content was dynamic server-side,
but still static client-side.
III. 2010-??: The JavaScript Age.
The JavaScript age is about event streams. Modern web pages are not pages, they are event-driven applications through which information moves. The core content vessel of the web — the document object model — still exists, but not as HTML markup.
The DOM is an in-memory, efficiently-encoded data structure generated by JavaScript.
LAMP architectures are dead because few web applications want to ship full payloads of markup to the client in response to a small event; they want to update just a fragment of the DOM, using JavaScript. AJAX achieved this, but when your server-side LAMP templates
are 10% HTML and 90% JavaScript, it’s clear that you’re doing it wrong.
To recognize this means shifting our view of the server from a document courier (HTML Age), or a template renderer (LAMP Age), to a function and data shipper. The principal role of the server is to ship an application to the client (JavaScript),
along with data (JSON), and let the client weave those into a DOM.
The secondary role of the server is to listen in on a stream for events (a new edit, a message, or ticker change) and efficiently push responses back to clients.
For both of these roles, node.js is an ideal serving architecture. Since we’re currying JavaScript functions on the server-side, we ought to write in JavaScript. We can shift computation from server to client with little impedance (for example,
we no longer need to maintain two sets of our custom string formatting libraries).
With regard to responding to event streams, node.js is ideal. Its asynchronous, non-blocking architecture means it’s incredibly fast. It uses HTTP 1.1, keeps its connections open, and a single server can handle thousands of open connections at once.
Finally, it’s worth considering that events are simply packets of data, and the emerging lingua franca of data on the web is JSON. This is what client-side applications receive when a ticker moves, or a message arrives. This is, again, a native
format for node.js.
The JavaScript age brings us closer to a web that is not a global digital library, but a global digital nervous system, whose implications we are only beginning to apprehend.
it’s early on, when your range of motion is highest.)
This decision was driven by a realization: the LAMP stack is dead. In the two decades since its birth, there have been fundamental shifts in the web’s make-up of content, protocols, servers, and clients. Together, these mark three ages of the web:
I. 1991-1999: The HTML Age.
The HTML Age was about documents, true to Tim Berners-Lee’s original vision of a “big, virtual documentation system in the sky.” The web was dominated by static, hand-coded files, which web clients crudely formatted (with defaults that offend even
the mildest of typographiles). Static documents were served to static clients.
II. 2000-2009: The LAMP Age.
The LAMP Age was about databases. Rather than documents, the dominant web stacks were LAMP or LAMP-like. Whether CGI, PHP, Ruby on Rails, or Django, the dominant pattern was populating an HTML template with database values. Content was dynamic server-side,
but still static client-side.
III. 2010-??: The JavaScript Age.
The JavaScript age is about event streams. Modern web pages are not pages, they are event-driven applications through which information moves. The core content vessel of the web — the document object model — still exists, but not as HTML markup.
The DOM is an in-memory, efficiently-encoded data structure generated by JavaScript.
LAMP architectures are dead because few web applications want to ship full payloads of markup to the client in response to a small event; they want to update just a fragment of the DOM, using JavaScript. AJAX achieved this, but when your server-side LAMP templates
are 10% HTML and 90% JavaScript, it’s clear that you’re doing it wrong.
To recognize this means shifting our view of the server from a document courier (HTML Age), or a template renderer (LAMP Age), to a function and data shipper. The principal role of the server is to ship an application to the client (JavaScript),
along with data (JSON), and let the client weave those into a DOM.
The secondary role of the server is to listen in on a stream for events (a new edit, a message, or ticker change) and efficiently push responses back to clients.
For both of these roles, node.js is an ideal serving architecture. Since we’re currying JavaScript functions on the server-side, we ought to write in JavaScript. We can shift computation from server to client with little impedance (for example,
we no longer need to maintain two sets of our custom string formatting libraries).
With regard to responding to event streams, node.js is ideal. Its asynchronous, non-blocking architecture means it’s incredibly fast. It uses HTTP 1.1, keeps its connections open, and a single server can handle thousands of open connections at once.
Finally, it’s worth considering that events are simply packets of data, and the emerging lingua franca of data on the web is JSON. This is what client-side applications receive when a ticker moves, or a message arrives. This is, again, a native
format for node.js.
The JavaScript age brings us closer to a web that is not a global digital library, but a global digital nervous system, whose implications we are only beginning to apprehend.
相关文章推荐
- 京JS 2013 - A two-day conference in Beijing for the JavaScript and Node.js community
- The Node.js Event Loop, Timers, and process.nextTick()
- Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a br
- Edge.js:让.NET和Node.js代码比翼齐飞(http://www.infoq.com/cn/articles/the_edge_of_net_and_node)
- The Twilio API and TwiML for node.js
- Node.js and the new web front-end
- Node.js: What is the best "full stack web framework" (with scaffolding, MVC, ORM, etc.) based on Node.js / server-side JavaScript? - Quora
- use noscript html tag when user disable the javascript in browser, guide user how to enable the js in different browser and retu
- nodejs采坑记录之-“Make sure you have the latest version of node.js and npm installed”
- [Node.js]30. Level 6: Listen 'Question' from client, and then Answer the Question
- [Node.js]三. Node.js的语法是与Javascript一样吗,Processs是什么?
- Node.js:用JavaScript写服务器端程序-介绍并写个MVC框架
- Benchmarks for the Top Server-Side Swift Frameworks vs. Node.js
- 跟着廖雪峰学 JavaScript - Node.js
- Electron学习一:Electron、Node.js、JavaScript、JQuery、Vue.js、Angular.js的不同
- Node.js https.request and https.get
- 使用 Node.js 开发基于 JavaScript 的 RESTful 应用
- [MEAN Stack] First API -- 1. with Node.js, Express and MongoDB
- 黑客与画家 Hackers and Painters: Big Ideas from the Computer Age
- sap.ui.require in SAP UI5 and require in nodejs