Content deleted Content added
Corrected invalid claims about "languages". PHP and JavaScript are both imperative languages, only the function design differs. |
Replace invalid ignorance about threading in Node.js with some proper educated information |
||
Line 49:
Frameworks can be used to accelerate the development of applications, and common frameworks are [[Express.js]], [[Socket.IO]] and Connect.<ref name="b1"/><ref name="b7">[https://books.google.com/books?id=5eGRAwAAQBAJ&printsec=frontcover&dq=nodejs&hl=en&sa=X#v=onepage&q=nodejs&f=false Express.js Guide: The Comprehensive Book on Express.js], Azat Mardan, 28-May-2014</ref> Node.js applications can run on [[Microsoft Windows]], [[Unix]], [[NonStop]]<ref name="bomBora - Node.js for NonStop"/> and {{nowrap|[[Mac OS X]]}} servers. Node.js applications can alternatively be written with [[CoffeeScript]]<ref name="b6">{{cite web |url=https://books.google.com/books?id=Oda-MgEACAAJ&dq=nodejs&hl=en&sa=X |title=CoffeeScript on Node.js |publisher=O'Reilly Media, Inc. |date=April 15, 2013 |accessdate=May 17, 2015}}</ref> (an alternative form of JavaScript), [[Dart (programming language)|Dart]] or [[Microsoft TypeScript]] ([[strongly typed]] forms of JavaScript), or any other language that [[Source-to-source compiler|can compile to JavaScript]].<ref name="b6"/>
Node.js is primarily used to build network programs such as web servers, making it similar to [[PHP]].<ref name="b2">[https://books.google.com/books?id=KZQQAlhTOBgC&printsec=frontcover&dq=nodejs&hl=en&sa=X#v=onepage&q=nodejs&f=false Node.js for PHP Developers], O'Reilly Media, Inc., 2013</ref> The biggest difference between PHP and Node.js is that most functions in PHP [[Asynchronous I/O|block]] until completion, while functions in Node.js are designed to post long lasting tasks to the underlying thread pool and then return to the caller in a [[Asynchronous I/O|non-blocking]] fashion. A registered [[Callback (computer programming)|callback]] is then called from the event loop to signal completion of the posted task. This allows enqueuing parallel tasks without explicit threading.<ref name="b2"/>
Execution of parallel tasks in Node.js is handled by a thread pool. The main thread call functions that post tasks to the shared task queue which threads in the thread pool pull and execute. Inherently non-blocking system functions like networking translates to kernel side non-blocking sockets, while inherently blocking system functions like file I/O run in a blocking way on its own thread. When a thread in the thread pool completes a task it informs the main thread of this, which in turn wake up and execute the registered callback. Since callbacks are handled in serial on the main thread, long lasting computations and other CPU-bound tasks will freeze the entire event-loop until completion.
Thousands of open-source libraries have been built for Node.js, most of which are hosted on the npm website. Its developer community has two main mailing lists and the [[IRC]] channel #node.js on [[freenode]]. There is an annual Node.js developer conference, NodeConf.<ref>{{cite web | url=http://www.readwriteweb.com/hack/2011/04/nodeconf-schedule-announced.php | title=NodeConf Schedule Announced | publisher=ReadWriteHack | date=April 7, 2011 | accessdate=2 August 2014 | author=Finley, Klint}}</ref>
|