Node.js — JavaScript, JS V8 Chrome. Node.js , -, . Node.js . Node.js. , .
Node.js :
Node.js — JavaScript . Node , . , , push-.
Node.js HTTP- . Node.js . , , , , , . Node , .
Node.JS , , . , .
Node.js — JavaScript
Node JavaScript, JS. Node.js , . JavaScript — Netscape. Microsoft Visual Basic, Sun Tcl, Perl UNIX REXX IBM. JavaScript , , C C ++. , , .
JavaScript - , -. , .
JavaScript , Java ( - , C ++).
JS
JavaScript -. Netscape -. JavaScript Java, C ECMAScript — , Sun Microsystems.
JavaScript — . , - , -. - . , JavaScript - , , . , - .
, PHP ASP, JavaScript HTML- . HTML , JavaScript -. .JS, .
JavaScript, . 7 11. HTML -, «18» .
<script>
function sum(a,b)
{
return a + b;
}
var total = sum(7,11);
alert(total);
</script>
JavaScript <script>, . onClick, onMouseDown, onMouseUp, onKeyDown, onKeyUp, onFocus, onBlur, onSubmit . JavaScript , - JavaScript, jQuery, - .
Node.js, , , / (I/O). Node.js , , . . Node.js , - , .
JavaScript , Node.js . , , Node, Ruby. : Node , Ruby, Python Java.
, Rails Node.JS? ? Node , , JavaScript Chrome . , Node.js — JavaScript C/C ++ , HTTP TCP-.
Node , . , . , .
Node.js :
(, EventMachine Ruby Twisted Python), Node .
Node.JS , , .
Node -, . (DIRT), , API JSON .
Node (NPM)
Node , . :
Node.js
Node Windows OS X, . NVM ( Node).
, , . , NVM Ubuntu.
-, , C ++:
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev
NVM :
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | hit
NVM , , , . :
$ nvm
, , . Node NPM.
:
$ nvm install v0.10.31
################################################## ################ 100,0%
npm :
$ node -v & amp; & amp; & amp; npm -v
v0.10.31
1.4.23
Node.JS :
$ nvm alias default 0.10.31
Node , , nvm use:
$ nvm install v0.8.10
, , nvm-list. , , :
list $ nvm
v0.6.3 v0.6.12 v0.6.14 v0.6.19 v0.7.7 v0.7.8 v0.7.9 v0.8.6 v0.8.11 v0.10.3 v0.10.12 v0.10.15 v0.10.21 v0.10.24 v0.11.9 : v0.10.24 default -> v0.10.24
Node.JS Java Python , PHP Ruby . Node CommonJS . , require.
, :
var http = require ('http');
var dns = require ('dns');
:
var myFile = require ('./ myFile'); // download myFile.js
NPM, - Github. :
# where express ===
$ npm install express
, , (CPS). (, ) .
IPv4- :
var dns = require ('dns');
dns.resolve4 ('www.google.com', function (err, addresses) {
if (err) throw err;
console.log ('addresses:' + JSON.stringify (addresses));
});
( ) dns.resolve4. async , , .
Node.JS , , . , , .
IRC-:
var irc = require ('irc');
var client = new irc.Client ('irc.freenode.net', 'myIrcBot', {
: ['# sample-channel']
});
client.on ('error', function (message) {
console.error ('error:', message);
});
client.on ('connect', function () {
console.log (« irc»);
});
client.on ('message', function (from, to, message) {
console.log (from + '=>' + to + ':' + message);
});
client.on ('pm', function (from, message) {
console.log (from + '=> ME: + message);
}).
:
EventEmitter.
EventEmitter , , . , .
Node EventEmitter , EventEmitter. MemoryWatcher, EventEmitter :
, Node - -, . JavaScript.