0

First of all, I'm an experienced js programmer, good also in php (exluding database design) but don't know much about how servers work.

I'm participating to a quite big projects that's about to start and I'm trying to figure out what's the best tecnology to use.

The application will be geolocalized, and will use google maps. It will have a lot of javascript rendering (probably on the front end I'll end up using backbone or ember, but still thinking). hopefully, it will be used by a lot of users. The will continuously receive data while moving around. Specifically, they'll receive data from clubs, pubs and so on. hopefully, it will coninuously grow over time, with new features, more data, more users.

I was wondering if node.js could be a good choice for developing it of it would be better to stick to more conventional php ways.

what do you think?

Luca Reghellin
  • 7,426
  • 12
  • 73
  • 118

2 Answers2

1

Since you are an experienced Js programmer, you shouldn't have a real problem using Node.js. You're already familiar with the language. If your application will send and receive data continuously, I recommend Node.js and socket.io, which enables real-time communication.

Ibrahim Yusuf
  • 313
  • 1
  • 6
  • ok, so you think node.js can be a good way of developing an app of that kind (that will also then be developed for mobile devices), over a more common approach? Excuse me if I ask again but I need to have as lot infos as possible. I didn't even fully understand by reading things about node, if it can be used to fully substitute a more conventional php application. I read a really long post here http://stackoverflow.com/questions/1884724/what-is-node-js where they say node WAS still a bit difficult to use in production apps, but it's an old post, so I guess things are better now.. – Luca Reghellin Sep 08 '13 at 14:33
  • Nodejs can be a bit difficult in production apps, depending on how you try to deploy it. Heroku is a very expensive option for a production app, but it is very easy to deploy and envolves no maintenance on your part. Using your own webserver can end up being more difficult than php, becuase there is no easy way to deploy like ftp for php. You problaby will have to ssh into your server to update everything when you want to update your app. – joshua-anderson Sep 08 '13 at 16:14
  • 1
    And I DON'T recommend socket.io. It's full of memory & cpu leaks from the very moment you use RedisStore (and thus, want to scale using clustering). You should use SockJS with your own pub/sub logic. – Mathieu Amiot Sep 08 '13 at 16:16
  • Yes - the best use of Node.js is the REST API on the server side, and rich clients on (rich web apps, where the logic processed using client side javascript like Backbone and Ember, mobile apps, and third-party developers). Using PHP will spawn a process **every time** it process a single request, which is not efficient since you said the application will send and receive data **continuously**. – Ibrahim Yusuf Sep 09 '13 at 15:57
1

Nodejs takes a lot more initial code than php(because there is no middleware server like apache, you have to program the server yourself), but can perform faster and has much better support for templates and websockets than php. If your maps application wants real time updating, then websockets are incredible, but there is no good solution in php at the moment. The only way to handle websockets in php is through external programs, because you can't control the php server.

One thing to consider if you are going to use nodejs is: Do you like callbacks? Unlike php, where everything is performed synchronously, in nodejs, almost everything is written in asynchronous callbacks, to prevent the server from seizing up while handling a big request. Some people like this coding style, others despise it and think it is a messy bunch of functions inside of functions inside of functions. I personally like this style but it is more complicated than php.

A lot of the choice depends on your team's personal preference. Spend a hour or two trying both with your team and seeing which appears to be working best for you.

joshua-anderson
  • 4,458
  • 5
  • 35
  • 56