37

I am totally lost of what Node.js is all about so here's my question:

Is node.js a new language which can replace PHP or it is a language which can/only compliment/supplement PHP and other web languages to perform complex task?

Orvyl
  • 2,635
  • 6
  • 31
  • 47

2 Answers2

27

Node.js is server side Javascript environment based on chrome V8 javascript engine. It enables you to write your server code in javascript, instead of choosing one of the "traditional" web languages such as PHP, c#, python, ruby, perl etc. Using node.js and database such as mongodb you could write your web application completely in javascript.

Here's example of the full stack for web development:

  • Backbone for client side, code that runs in the browser (chrome,firefox)
  • Express server side framework running on Node.js
  • Mongodb database for storing documents

Above mentioned technologies will enable you create your application writing only javascript code, from browser to server and finally to database, sort of one language to rule them :), no need for PHP unless you have legacy codebase .

slobodan.blazeski
  • 1,040
  • 9
  • 20
  • 1
    what do you mean by legacy database? – Orvyl May 05 '13 at 12:29
  • Sorry I meant codebase. – slobodan.blazeski May 05 '13 at 12:59
  • then what is codebase – Mahi Nov 27 '16 at 08:34
  • 1
    @Mahi https://infogalactic.com/info/Codebase – slobodan.blazeski Nov 27 '16 at 21:35
  • @slobodan.blazeski thank you . can i build web apps using above mentioned technologies ?? – Mahi Nov 28 '16 at 05:24
  • @Mahi Backbone is kinda dated, I'd suggest to replace it with React everything else Node, Express & MongoDB is already mainstream technology, – slobodan.blazeski Nov 28 '16 at 13:08
  • Look like pretty biased answers to me. No mention of what's the difference, nor why it should be better than other languages, what are the drawbacks, nor the difference in the the learning curve: PHP is definitely faster to grasp and get productive with in the beginning, than JS; the latter requires a deeper confidence with the environment/scope/context. React is also a good tool but takes quite some effort to grasp (there are alternatives). Downvoted, sorry, but the "best" answer just suggests the trends, without helping the user to choose and misleading her; the other answer is imo better. – Kamafeather Mar 23 '19 at 11:56
7

First you have to understand the difference between server-side and client-side code.

Server-side code runs on the server, and it can do stuff like reading a database, getting file contents from the server, send mails etc. Examples of server-side code are PHP, Node.js, ASP.

Client-side code runs in the users webbrowser. It is used to make webpages interactive. This is mainly written in JavaScript.

PHP and Node.js are both server-side programming languages (altough node is a framework, but lets not make this any more complicated). They can both do things like database processing, reading files. As far as I know, you can't use both PHP and Node.js at the same time, so they can't even work together (there is probably some way to achieve this)

So to wrap it up: Node.js and PHP are both server-side and they can do the same thing. Node.js can replace PHP and vice versa

Dirk
  • 2,094
  • 3
  • 25
  • 28
  • Thank you. I am currently creating an live notification like facebook and they said that node.js is perfect for this.However, im currently using code igniter(php framework) and I'd assume that node.js is like javascript which you can integrate directly into the site. Thank you so much for answering. – Orvyl May 05 '13 at 12:27