why and how you should move from php to node.js

36
Why & How You Should Move from PHP to Node.js

Upload: brainhub

Post on 07-Jan-2017

2.541 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Why and How You Should Move from PHP to Node.js

Why & How You Should Move from PHP to Node.js

Page 2: Why and How You Should Move from PHP to Node.js

Piotr Kowalski CTO @Brainhub

Page 3: Why and How You Should Move from PHP to Node.js
Page 4: Why and How You Should Move from PHP to Node.js

Because it’s 2016!

Page 5: Why and How You Should Move from PHP to Node.js

Because it’s 2016!

Page 6: Why and How You Should Move from PHP to Node.js

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

What is JavaScript?

Page 8: Why and How You Should Move from PHP to Node.js

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

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

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
Page 12: Why and How You Should Move from PHP to Node.js

Asynchronous event loop with non-blocking I/O

Page 13: Why and How You Should Move from PHP to Node.js
Page 14: Why and How You Should Move from PHP to Node.js

Asynchronous event loop with non-blocking I/O

Page 15: Why and How You Should Move from PHP to Node.js

Node Package Manager

● Packages count: 344694 (as for today)

● Actively developed

Page 16: Why and How You Should Move from PHP to Node.js

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

Fast prototyping and pivoting

Page 18: Why and How You Should Move from PHP to Node.js

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

One can build a desktop app● Electron

● NW.js

● APPjs

Page 20: Why and How You Should Move from PHP to Node.js

Many frontend frameworks

Page 21: Why and How You Should Move from PHP to Node.js

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

WebSockets is a future of the Web (IMO)

Page 23: Why and How You Should Move from PHP to Node.js

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

One can run it even on a coffee machine

Page 25: Why and How You Should Move from PHP to Node.js
Page 26: Why and How You Should Move from PHP to Node.js

<

Page 27: Why and How You Should Move from PHP to Node.js

How should I start?

Page 28: Why and How You Should Move from PHP to Node.js
Page 29: Why and How You Should Move from PHP to Node.js

Read some bookshttps://github.com/getify/You-Dont-Know-JS

Page 30: Why and How You Should Move from PHP to Node.js

Read some bookshttp://shop.oreilly.com/product/9780596517748.do

Page 31: Why and How You Should Move from PHP to Node.js

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

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

Choose some framework

Page 34: Why and How You Should Move from PHP to Node.js

Play around and bring your ideas to life!

Page 35: Why and How You Should Move from PHP to Node.js

Come to the next #devduck!

Page 36: Why and How You Should Move from PHP to Node.js