Friday 16 December 2016

Why I built today's project with Node vs PHP, and fell in love

Synopsis: need a recursive system where items can have parents, have children or not, and possibly be orphans themselves.Requirements: server side rendering, high concurrency, tight securityPHP Pros: Well, its PHP, pretty straight forwardPHP Cons:Security was a concern. We need to accept uploads from unknown origins, unknown types. I'm looking at you "GIF98"Bigger reason: the blocking nature of PHP was a deal breaker, so it kills the concurrency requirement.Node Cons: I'll start with the cons for NodeJS, not many.Lots of non-blocking pyramid of death function call backs, I guess thats the first. That's mitigated by breaking the code into smaller pieces. Same can be achieved in PHP thoughServer front door is apache. However, ProxyPass, you magical bastard :) Not really a con after allNode Pros:NPM rocks. We get the same thing in PHP with composer, but its on a different level in Node worldDefined routes (via Express) which mitigates file upload vulnsTotally non blocking. "Here is the code I want you to run whenever you finish this function call".... love itTemplating, Jade: Specifically, being able to pass an array of objects returned from a database query and build the interface using widgets.My last Node build out was an API with a ReactJS front-end running in the client. Great solution, I highly recommend that combo when it meets the project's requirements, such as reduced network traffic and low server resources.But for today's project, straight up Node/Express and server side rendering was a dream to work with.

Submitted December 17, 2016 at 02:49AM by terrible_name

No comments:

Post a Comment