Google Chrome's native client is soon to be released. http://blog.chromium.org/2011/02/native-client-getting-ready-for-takeoff.html Would this allow node.js to be run within the browser enabling distributed applications to communicate with each other without having to go through the server?
4 Answers
Nowadays there are several solutions that allow you to run some Node modules in chrome. Have a look on these links:
node-webkit is an app runtime based on Chromium and node.js.
Node-chromify, Node.js in Chrome.
Screen cast from google about NodeJS in Chrome packaged apps.

- 378
- 3
- 12

- 13,540
- 5
- 39
- 48
As of today, Node.js will not run in NaCl, however it may be possible eventually. Node uses the V8 JavaScript engine to execute code. Currently there is no reliable port of the V8 engine that will run within NaCl.
From a comment by Brad Chen on Jan 28, 2014, in the thread "Has anyone tried porting Blink and V8 to Native Client?":
V8 has been ported to Native Client, although the port used an unsavory trick of having V8 generate ARM instructions and then use a portable ARM interpreter to avoid the need to port V8 code generators to NaCl. You should be able to observe this by checking out V8 source and following the standard build/test instructions using targets nacl_ia32 or nacl_x64.
https://groups.google.com/d/msg/native-client-discuss/Xw5yCe3Ubwc/fgm6M092DXwJ
Considering that V8 has already been able to run under NaCl, albeit with an unreliable hack, it's reasonable to assume that Node might eventually be able to run in NaCl. I realize your question is now three years old but figured I'd provide an updated answer since running native code (even OpenGL code) in the browser is now a reality.

- 758
- 6
- 15
node.js is not pure Javascript code. There are parts of it written in C++ so this is unlikely.
There are a couple of possibilities for distributed communication. One is to use the Websockets api in the browser to communicate with other browsers. The other one is to run node.js as a separate server process on the same machine as the browser.
This second is a better choice for building a distributed application because it reduces dependence on the browser. Version 0.5.0pre of node.js now builds OK on Cygwin and it is possible to bundle up the essential components of Cygwin as a standalone binary to distribute to Windows clients. Older versions of node.js used to be distributed this way.

- 31,973
- 6
- 70
- 106
-
2node is written in C: http://hackermedley.org/new-web-tech/ As the native client for chrome will allow native code to be used within the browser, I thought maybe node could be used.. – Sycren Feb 22 '11 at 17:26
-
I recently built 0.5.0pre of node.js and the src folder is full of .cc files with lines like this: static Persistent – Michael Dillon Feb 22 '11 at 17:36
-
1@Sycren: That depends on how you define written. Node.js is mostly V8 and V8 is C++! – ase Feb 22 '11 at 17:37
-
As Chrome uses V8 as its javascript engine, would it be possible for nodeJS to work together with Chrome? If only in theory. – Sycren Mar 29 '11 at 18:01
You can't run Node.js in a browser.
However, if you want to do P2P connection, it's possible if the browser has the latest version of Flash (Flash 10) installed. In the latest version, they introduced RTMFP which let's you do P2P connection without passing through a server. If you want to use it in Javascript, you can make a bridge or you can take a look at a project I started recently that does exactly that.

- 10,985
- 5
- 42
- 67
-
I was looking for a way of distributing an algorithm for protein folding to other computers in a bittorrent like way. Although it is impossible to run node.js now, I was hoping that sometime in the future it may be possible – Sycren Feb 23 '11 at 22:43
-
@Sycren You can take a look at [BOINC](http://boinc.berkeley.edu/) which is made for things like that. It's not browser based, but desktop based tough. – HoLyVieR Feb 24 '11 at 01:05
-
I was looking at doing it through the browser as this will become more important later on in the future.. I was also hoping that in a way programming in javascript would mean 1 set of code rather than something slightly different for each operating system a bit like the java virtual machine. Although you could argue that browsers will use js differently, I dont think mathematical functions by browser will change too much – Sycren Feb 25 '11 at 14:56
-
@Sycren To do calculation for things such as `protein folding` you shouldn't be doing that in Javascript and in a browser. Javascript doesn't natively support big number and can't do parallel processing. If you do heavy calculation in a browser webpage, that webpage will just stop responding and browser will probably stop the script automatically. If you want to do grid computing, BOINC is probably the way to go. I never used it personnally, but I know it's being used a lot to do scientific calculation on a large scale. – HoLyVieR Feb 25 '11 at 18:00
-
While I understand this, I would be using it in a different way. Recent updates in browsers allow hardware acceleration and in the future perhaps we will see openCL or CUDA. Early experiments can already be seen with Chrome. By doing calculation with native code running on the gpu & cpu with an interface and communication through the browser. – Sycren Mar 29 '11 at 17:58