SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is node.js a replacement for PHP?

    If so, why bother with PHP? You have to use javascript anyway, right?

    Have to wonder, why is there no Wordpress, or Drupal, or whatever for node.js?

    From what little I have seen, node.js seems like a lot of work to just output "hello world."

    BTW: I know very little about this, if you couldn't tell.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    People are starting to bring out Node.js-based CMSes, but they are pretty limited. Node advocates are pretty clear on the point that it is useful for certain things and not all sites. There are far fewer hosts available for Node as well.

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    It'll partly depend on what's for, you have to keep in mine that generally javascript can be controlled and altered by the user so it can't be relied upon for sanitizing any input from the user. Also if a website relies on node.js (or any other javascript library) too much and the user has javascript disabled then that site will probably be broken as far as the user is concerned and they may say to their friends that the site is broken.

    Any site should be able to function perfectly well with javascript disabled, albeit it might take extra clicks to do some things
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    It'll partly depend on what's for, you have to keep in mine that generally javascript can be controlled and altered by the user so it can't be relied upon for sanitizing any input from the user. Also if a website relies on node.js (or any other javascript library) too much and the user has javascript disabled then that site will probably be broken as far as the user is concerned and they may say to their friends that the site is broken.

    Any site should be able to function perfectly well with javascript disabled, albeit it might take extra clicks to do some things
    To clarify, node.js is not a client side js library, but rather a server side server that runs javascript and works regardless of whether the browser has client side javascript enabled. The same way browsers can't "disable" php.
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Addict bronze trophy
    Join Date
    Apr 2013
    Location
    Ithaca
    Posts
    351
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    It sure can work out for a few applications, but not for everything. If node is this powerful as hyped, it would've overtaken PHP already at this moment. We dont see this coming, so clearly both node and PHP have their own uses. Node.js may be a close substitute for PHP, but not a perfect substitute that does everything better.

  6. #6
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Hall of Famer View Post
    It sure can work out for a few applications, but not for everything. If node is this powerful as hyped, it would've overtaken PHP already at this moment. We dont see this coming, so clearly both node and PHP have their own uses. Node.js may be a close substitute for PHP, but not a perfect substitute that does everything better.
    Node.js is not ideally for any web application. So it will not overtake PHP. But it is very efficient in handling large number of requests, I/O connections, works great with web-sockets, and comet pulling.
    It is an single threaded, event driven, non-blocking language.

    That means it does not block I/O connections (Ex. database queries, file read/write, net connections) like other blocking languages (Ex. PHP) does, instead it will register it as an event to the event emitter. When the connection is completed and the application finishes handling any other events, it will handle that event. This considerably improves performance, because the application does not wait for a blocked connection.

    On the other hand, the disadvantage of Node.js is that if a event needs to do a lot of computing it will block the event emitter until the current event is finished, and therefore any other events will not be handled until the current event is completed.

    This information is from my personal knowledge and is possible not to be 100% accurate.

  7. #7
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,398
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ratoi_crysty View Post
    Node.js is not ideally for any web application. So it will not overtake PHP. But it is very efficient in handling large number of requests, I/O connections, works great with web-sockets, and comet pulling.
    It is an single threaded, event driven, non-blocking language.
    To put this in a different way, Node is idea for writing apps where you need realtime communication between the browser and the server. Examples of this might be chat rooms and stock trading apps, I can imagine it would also be useful where remote control of devices is required (i.e motorized camera systems).

    As others have mentioned, you can use Node to write conventional apps such as CMSs, but there's no real advantage over more common languages such as PHP, and there are disadvantages like less hosting options, and it's probably going to be harder to find Node developers.

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by fretburner
    Node is for writing apps where you need realtime communication between the browser and the server.
    I wonder if web sockets will take over in that respect. Interesting times ahead.

  9. #9
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,398
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ralph.m View Post
    I wonder if web sockets will take over in that respect. Interesting times ahead.
    My understanding of it is that web sockets are part of the puzzle.. they are the technology you use to make the connection between browser and server, but you still need a server that can manage realtime connections. I have seen an experimental PHP web socket library, but I was under the impression that Node.js would perform much better in this sort of scenario due to the way it works.

  10. #10
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    What sounds interesting to me is how web sockets use a new protocol that allows for two way communication, unlike http, which is what Node is stuck with. (But beyond that I have no idea about this stuff. )

  11. #11
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,398
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by ralph.m View Post
    What sounds interesting to me is how web sockets use a new protocol that allows for two way communication, unlike http, which is what Node is stuck with. (But beyond that I have no idea about this stuff. )
    Node can use web sockets, with the socket.io module. But I agree, interesting times for sure!

  12. #12
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Ah, I see. Thanks for clarifying.

  13. #13
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use node in conjunction with PHP quite easily. Using node as a web service platform which provides business logic for a slim PHP web application would be a pretty efficient use of resources. A lot of CMS systems can get difficult to graft complex business logic to. If you keep the CMS as an easily customizable interface for non-technical users which gets it's business logic from services provided by tools like node, You have a very modular easily modified system.

    This isn't a competition or at least it shouldn't be between PHP and other platforms. They are all tools we can use to make great things. Thanking of it as a big context can limit your options as a developer.
    Visit my blog
    PHP && Life
    for technology articles and musings.

  14. #14
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey....I recently started working on a few Node.js applications. Coming most recently from PHP, I found the transition to Node.js to be surprisingly easy. If Node.js is found to be easy to use the surely it overtake PHP.

  15. #15
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,398
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    If anyone is interested, there's an article on realtime PHP apps in this month's Web & PHP Magazine which talks a little about the Node.js, PHP and web socket stuff.

  16. #16
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Have to wonder, why is there no Wordpress, or Drupal, or whatever for node.js?
    Node is newer, and has neither attracted a sufficient number of newbie-programmers nor gotten on cheap-1-dolla-no-holla web hosters yet.

    If node is this powerful as hyped, it would've overtaken PHP already at this moment.
    Plenty of languages are more powerful, easier to learn, better written and have more tools/libraries than PHP. If they're so great and wonderful, they would have overtaken PHP already at this moment.

    Or rather, PHP is popular for reasons that have nothing to do with power, easy learning, better written or having more tools/libraries. No reason for Node.js to be able to change that, though who knows, maybe in the future it will, *if* one-dolla-no-holla hosters start offering it by default like they do PHP now.

    Node.js is not ideally for any web application. So it will not overtake PHP. But it is very efficient in handling large number of requests, I/O connections, works great with web-sockets, and comet pulling.
    It is an single threaded, event driven, non-blocking language.

    That means it does not block I/O connections (Ex. database queries, file read/write, net connections) like other blocking languages (Ex. PHP) does, instead it will register it as an event to the event emitter...
    Most languages with any web use have the same ability, either via a framework (Python's twisted), a module (Perl's Any::Event), or just building from scratch any set of green threads/greenlets/whatever event loop system floats your boat + workers with a pubsub setup (they get spawned, they do their thing, they die). I don't know what's going on in the PHP world but I see above me fretburner's link to similar things. A language does not have to "be blocking" by default. It's like saying Language X isn't functional because people tend to write procedurally in it. If it's got first-class functions, you can write higher-order (functional) programs in it.

    Similarly, I've seen people presenting talks showing their Node programs going into Callback Hell, which must've been a limit to the V8 engine since ecmascript itself has promisses and stuff already built-in.

    I think it may be more like, people who do web programming are used to the once-revolutionary-but-now-common OO style programming, and procedural programming. So those using languages like Erlang tend to be using it because they wanted to do something else in the first place, so for example while you could build a web site/app in Erlang, not many people do it. But then I think it's a bit of a punch in a language's stomach to say it's not necessarily ideal for a web app. More like the particular programmer's personal preferences and what they're already familiar with.

    I'm sure as more people get into node, for whatever reason, more things like web frameworks will be developed for it, and simply more people will be using it. Hey, it happened to PHP.

  17. #17
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    What I would like to see the results of at some point would be a comparison of a site with different versions using:

    • Node.js Only
    • Part Node.js & Part PHP
    • PHP Only


    For each one with various levels of site traffic from very light to very busy. With each being tested for how secure they are various threats and attacks such as XSS and SQL Injection. Until I see such results I can't really say whether I'll ever give Node.js a try
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  18. #18
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    With each being tested for how secure they are various threats and attacks such as XSS and SQL Injection.
    To be fair that's 99% up to the developer to make sure stuff like that doesn't happen. Put a toddler in a Ferrari, that sort of thing.
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  19. #19
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMO it will take quite some time for people to navigate away from PHP to node.js -- PHP has such a massive ecosystem with many great products built on top of it.

    Node.js is fundamentally quite different from PHP. I also think Node.js (being based on JS) is superior to PHP in most every way. There is a growing community of developers learning node.js and it's various frameworks but I think it will be sometime before you see blogging engines (Google GHOST it looks awesome) become as popular and ubiquitous as WordPress.

    Alex

  20. #20
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Josette posted this interesting link: Async processing with PHP and GAE.

  21. #21
    SitePoint Addict bronze trophy
    Join Date
    Apr 2013
    Location
    Ithaca
    Posts
    351
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Interesting, I saw an article a while ago about how you can achieve async programming with PHP by using shell_exec(). The problem is though, for people writing software or applications for others(like a CMS or forumware), they have to compensate for client users running with shared hosts. Shared hosts do not normally enable shell_exec() unfortunately. I wonder how Amy Unruh's techniques works though, hopefully it does not involve anything that requires shell/linux command execution.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •