Why and How You Should Move from PHP to Node.js
Transcript of Why and How You Should Move from PHP to Node.js
![Page 1: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/1.jpg)
Why & How You Should Move from PHP to Node.js
![Page 2: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/2.jpg)
Piotr Kowalski CTO @Brainhub
![Page 3: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/3.jpg)
![Page 4: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/4.jpg)
Because it’s 2016!
![Page 5: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/5.jpg)
Because it’s 2016!
![Page 6: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/6.jpg)
Some thoughts about PHP (my personal selection)● Got used to HTTP (rather request processing than application)
● Many PHPisms, inconsise API (past days)
● Many libraries from many sources
● Tremendous community
● Pretty adult
![Page 7: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/7.jpg)
What is JavaScript?
![Page 8: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/8.jpg)
Brief history● Written in 10 (!) days of May 1995 (name: Mocha)
● Deployed in Netscape Navigator 2.0 in December same year
● Standarisation process since 1996 - ECMAScript
● Browser wars
● Many descendants - JScript, ActionScript and so on…
● NOT DEAD!
![Page 9: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/9.jpg)
What is JavaScript not a.k.a. popular myths● Given a web page, add me some animation magic
● Do me some AJAX magic
● Some stuff that cannot be kept tidy
● Works different on every browser
● You write $ then some CSSish selector, then you do stuff
● It’s only for the Web
● Some people call it node, but I have no idea why
● There are no classes, it’s not real OO language
● Everyone knows JavaScript, so why bother?
![Page 10: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/10.jpg)
What about node.js?● A V8 JavaScript engine
● Multiplatform
● Versatile
● Fast (in a runtime)
● Actively developed (current version 7.0.0)
● ...some more
![Page 11: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/11.jpg)
![Page 12: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/12.jpg)
Asynchronous event loop with non-blocking I/O
![Page 13: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/13.jpg)
![Page 14: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/14.jpg)
Asynchronous event loop with non-blocking I/O
![Page 15: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/15.jpg)
Node Package Manager
● Packages count: 344694 (as for today)
● Actively developed
![Page 16: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/16.jpg)
Realtime application > processing requests● A web server works as a continuous process, doesn’t restart everytime a new
HTTP request is coming
● Can be stateless, but don’t have to be so
● We can get beyond the HTTP (WebSockets, HTTP2, SPDY and so on)
● Does a web server should only create response?
![Page 17: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/17.jpg)
Fast prototyping and pivoting
![Page 18: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/18.jpg)
Scalability● Horizontally scalable
● Since it runs a process it can be easily ran on multiple machines and load
balanced
● Thin runtime environment
![Page 19: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/19.jpg)
One can build a desktop app● Electron
● NW.js
● APPjs
![Page 20: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/20.jpg)
Many frontend frameworks
![Page 21: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/21.jpg)
Isomorphic front- and backend● Common codebase both for the backend and the frontend
● No more redundant code!
![Page 22: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/22.jpg)
WebSockets is a future of the Web (IMO)
![Page 23: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/23.jpg)
Node native extensionsOne can write native modules/extensions to node.js (C/C++/Objective-C)
![Page 24: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/24.jpg)
One can run it even on a coffee machine
![Page 25: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/25.jpg)
![Page 26: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/26.jpg)
<
![Page 27: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/27.jpg)
How should I start?
![Page 28: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/28.jpg)
![Page 29: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/29.jpg)
Read some bookshttps://github.com/getify/You-Dont-Know-JS
![Page 30: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/30.jpg)
Read some bookshttp://shop.oreilly.com/product/9780596517748.do
![Page 31: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/31.jpg)
Read some bookshttps://www.manning.com/books/secrets-of-the-jav
ascript-ninja
![Page 32: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/32.jpg)
Subscribe to some blogs/feeds● http://www.echojs.com/
● https://davidwalsh.name/
● http://jstherightway.org/
● https://www.sitepoint.com/
● https://medium.com/@dan_abramov
● http://javascriptweekly.com
![Page 33: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/33.jpg)
Choose some framework
![Page 34: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/34.jpg)
Play around and bring your ideas to life!
![Page 35: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/35.jpg)
Come to the next #devduck!
![Page 36: Why and How You Should Move from PHP to Node.js](https://reader031.fdocuments.net/reader031/viewer/2022030305/587082e21a28ab57368b6d03/html5/thumbnails/36.jpg)