This presentation takes you through the basic features of PHP and Node.js and the difference between them. It also suggests some of the popular frameworks for each of them.
It is one of the tech-talk presentations from SquareBoat. Follow us on SlideShare for upcoming presentations.
2. PHP is a server-side scripting language designed for web development but also used as a general-purpose
programming language.
Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by
The PHP Group.
PHP originally stood for Personal Home Page, but it now stands for the recursive backronym PHP:
Hypertext Preprocessor
3. ● Node.js is an open-source, cross-platform JavaScript run-time environment for executing
JavaScript code on server-side.
● It was originally written by Ryan Dahl in 2009.
● It is built by combining Google's V8 JavaScript engine, an event loop, and a low-level I/O API
● Dahl was inspired to create Node.js after seeing a file upload progress bar on Flickr
7. Why NodeJS?
Traditionally for each connection (request) we
spawns a new thread, taking up system RAM
and eventually maxing-out at the amount of
RAM.
Node.js operates on a single-thread, using
non-blocking I/O calls, allowing it to support
tens of thousands of concurrent connections
(held in the event loop).
8. NodeJS in brief
● Server side Javascript
● Built on Google’s V8 Engine
● Event driven, non blocking I/O
● CommonJS module system
● 8000 lines of C, C++ Code (at the time of release)
● 2000 lines of Javascript (at the time of release)
● 14 Contributors (at the time of release)
9. NodeJS equals to
Code written in C,
providing some
functionalities to
make a server
Javascript Runtime
Environment
+
Some more JS
code and some
library like
CommonJS
+
13. The process goes into the worker thread, does a task as come back when its work is
done.
But how do they magically re-appear in the main thread.
There is a queue, which is maintained to store which worker thread is completed.
Now there is a dedicated worker thread, whose work is to constantly ping the queue
to check is some new task is completed. If there is a callback in the queue it then
checks the main thread if its idle then pass the callback to run else if busy then wait
for it be to get freed.
This dedicated worker thread is known as Event Loop.
Lets see it in working, Loupe
14. Coding Style
● PHP
○ As we’re all familiar with PHP’s coding style and we know that its very linear. Trying to multitask in PHP is a
schlep.
○ As we go on writing code, a developer knows that the flow for processing that particular code will be same as
its written (line-by-line).
● NodeJS
○ The major advantage here is asynchronous. Pretty much everything is multitasking.
○ Due to this, a developer must write the code in such a style so that he/she can handle the requests made by
multiple clients efficiently.