DEV Community

Discussion on: Node vs PHP

Collapse
 
xroal profile image
Roman Stejskal

Node all the way.

JavaScript syntax is much nicer than PHP, also more concise, and actually OO. JavaScript doesn't need special handling of UTF-8, unlike PHP, where my scripts very much like to save mumble-jumble into the database instead of the actual characters.

Node also has a proper package system, which lack of has bitten my ass many times in PHP (when the official docs tell to you composer install a package but you actually can't because a third dependency of both of them has a version mismatch... Looking at you, Lumen), but never in Node, where each package can require its own version of anything and it just won't clash.

TypeScript.

Also, native JSON support is nice when working with JSON based REST APIs or services in general.

Collapse
 
tdias25 profile image
Thiago Dias

when people say simple sh*t like this i can't do nothing but wonder what the engineers who made complex frameworks such Symfony and ZEND would say lol

Collapse
 
razbakov profile image
Aleksey Razbakov

JavaScript syntax is much nicer than PHP

Can you please share some nice projects in Node? Do you consider this github.com/HugoDF/express-bull-es6 as a good practice?

I am lacking some abstraction and organization of the code that PHP has.

Collapse
 
xroal profile image
Roman Stejskal

You can take a look at Example Node (Express + Mongoose) codebase containing real world examples.

What I meant specifically by syntax is, e.g.,

  • no $ for variables,
  • object literals { key: value } vs [ 'key' => value ],
  • anonymous functions (args) => retVal vs function (args) use (vars) { return retVal; }

What abstractions and organization of code do you mean?

Collapse
 
nerdlyist profile image
Coury Ryan Richards

Composer works great and you can 100% specify versions. Also, composer is the only one which do you prefer npm, bower, yarn... whatever comes next.

Syntax is an opinion. I mean don't get me wrong php could have helped itself with naming and parameter ordering consistency. Some people like ruby and I know cold fusion evangelist.

PHP has type hinting or you could move to Java or .net if you wany types and "actual oop/d".

Json is pretty straightforward with json_encode/json_decode. Where a lot of other languages you need an entire library to make that work on complex objects (no not js).

As for the question. I would say js/node are hot to trot right now. There are a lot of companies willing to pay top dollar for that skill set.

If you are starting a company though php can get all the work done for a fraction of the cost. Php developer (who creat the same systems) are very underpaid.

Also, realize whatever is best right now won't be in 10 years and you should always be evolving your skillset.

Also realize that best is very tricky and depends a lot on what you are doing.

My personal experience is Java, python,php and js. But I've gotten stuff done in ruby, cold fusion and .net.

Server wise node for js seems pretty standard. PHP has Apache mod-php which is well documented. If you are making an API I think php-fpm would be a good alternative although I usually run into issues when it comes to returning static content like images or css files. Still have not found a good solution for that without some hacky methods.