Differences between Node and JavaScript Javascript

I was always a little annoyed that there are two main areas of javascript projects - Node and “browser” - and while most JS browsers can be easily launched inside Node using several libraries for the DOM, if necessary, porting Node material to the browser is usually belated thought.

All of this looks like most of the wasted energy from the developer communities, which can be mitigated by all JS developers who are just designed for the “least common denominator” (browser) and use different paddings to use features available only in Node or other JS environments , besides the usual old browser.

This would not only cut out the steepness of the ecosystem and make development in the browser more realistic, but also make it trivial to give the browser superpowers ... Look at the browserver example, which installs an HTTP server inside the browser, but since the browser cannot accept HTTP requests It uses web ports to talk to the proxy Node server, which can.

So, I want to ask, what are the real technical limitations of the javascript web browser environment versus Node? I thought Node was just a "javascript environment, plus an http server and local file system, minus the DOM and chrome." Are there any technical reasons why developers cannot move on to the approach described above while developing the JS browser environment (does this have an official name?) And uses padding for Node?

+5
source share
1 answer

The code that runs on the client usually has very different goals from the code that runs on the server. However , when it makes sense to use some libarary functions in both environments, there are many of them that are defined using the universal form of AMD, which makes them platform independent (for example, Q ).

The main difference between the two environments is that each of them is subject to strict security policies and restrictions (browser), while the other is not. The browser is also an unreliable environment for security-related operations, such as enforcing security permissions.

I will also add a comment @ jfriend00 here, as I believe that it is also very relevant for other differences:

The biggest difference is that you need to create a browser application to work in the installed base of existing browsers including older versions (the lowest common denominator). When deploying a node, you can select the ONE version of the node so that you want to develop and deploy. This allows node developers to use the latest features in node that will not be available for many years. @ Jfriend00

Projects like the browser are interesting, and I'm all for experimental development, but are they really useful in practice? Libraries must be designed for the environment in which they are truly useful. There are no benefits to creating all the libraries in both environments. Not only does this usually lead to increased code complexity, some functions will sometimes not be smoothed, which will lead to an inconsistent API between platforms.

+3
source

All Articles