问题
What are the major differences between the Netscape Enterprise Server implementation of Server-Side JavaScript (SSJS) and the node.js implementation?
Why did Netscape's implementation not gain traction while the node.js one seems to be far more popular?
回答1:
Back in 1999/2000, I used to work at a company that used Netscape Server and SSJS. I don't know how popular it was at the time, but from first hand experience, I can tell you that almost everything about it was terrible:
- It was a giant pain to debug (any changes to source files, even static files, required full reloading of the application, which was not a fast operation)
- A simple error (such as an uncaught exception) often would lead to catastrophic server failure. Somewhat amusingly, this is the default behavior of NodeJS, although it is much easier to get around this problem with Node.
- Although the syntax was JavaScript, it failed to implement one key advantage of modern JavaScript: runtime interpretation. Server Side JS with Netscape Server required compilation before deployment, and therefore dictated a very slow development process.
- It followed a multi-threaded execution model (rather than modern JS VMs, which are almost always event-loop based)
- Possibly it's biggest weakness was a lack of asynchronous programming support. All IO operations were blocking, and as such it required a heavyweight multithreaded model to support multiple clients. The execution model was more similar to a J2EE container than to modern event driven JavaScript VMs (ie: V8). In my opinion, this is the number one thing that NodeJS gets right: the async philosophy is deeply embedded in the NodeJS development workflow and it is the key to its lightweight, event driven, extremely efficient concurrency model.
Just for giggles, here's a link to the SSJS reference guide from version 1.2 . Starting on page 21, you can see all the standard functions and synchronous APIs for file objects, database queries, etc...
My company ended up switching to ColdFusion shortly thereafter and never looked back.
回答2:
The main difference would be the evolution of Javascript over the the past 15+ years. Node.js uses the V8 Javascript Engine which would be far more optimized for modern computers.
Wikipedia has a good list of the differences between various server-side JS solutions.
Here is a list of features for Netscape Enterprise Server - provides a good idea of what makes modern SSJS solutions much better.
Why did it not gain attention? Realistically, client-side JS has only recently started to become the standard for web development so it was unlikely anybody would have considered using it for server-side development when it wasn't even really widely adopted for it's original purpose. I say widely adopted in that previously it was always difficult to cater JavaScript solutions to all browsers.
来源:https://stackoverflow.com/questions/18350910/netscape-enterprise-server-and-server-side-javascript-ssjs-vs-node-js