News for hackers. Stuff that matters.
Re:RailwayJS by rockyj on Monday October 01, 2012 @02:30AM (#4595615)
The main reason Node.js is gaining popularity is because it is blazing fast, scales very well due to its IO + event driven architecture and it has the best support for websockets (see socket.io).

On the flip side, code can be hard to maintain and you need to be more disciplined so that you can read the code later otherwise it becomes a callback spaghetti. Doing everything through callbacks also requires a mental shift.

Like with everything in life, there are pros and cons and tradeoffs. So choose wisely :).

Re:RailwayJS by jaequery on Monday October 01, 2012 @02:53AM (#4595671)
node.js isn't really that fast for traditional apps, but if you were to compare, it's pretty much on levels of nginx and it's actually slower serving static files. only in few cases node.js shows its power, i.e; real-time apps/games. i wouldn't build any full-blown websites in node.js. only a certain piece on the site i'd do it in node, like a widget or something.
Re:RailwayJS by louischatriot on Monday October 01, 2012 @04:27AM (#4595853)
Yep, you shouldn't be using node to serve static files anyway. This is something a reverse proxy such as nginx should do. Node can then be used to serve either as a pure API (serving json with express is the easiest way) for a webapp or render the webpages.
Re:RailwayJS by wamatt on Monday October 01, 2012 @04:57AM (#4595909)
nginx is not a bad choice, but would instead recommend node-http-proxy for most projects (including production).

It's fast, easy to setup (npm install), and relatively hardened, while still keeping everything JS.

As for static assets, those should probably be served from a CDN anyway, if one is concerned with performance.

Re:RailwayJS by louischatriot on Monday October 01, 2012 @09:15AM (#4596774)
I agree about the CDN, even though for us performance is not so critical we need to use a CDN (yet). I didn't know node-http-proxy but it sounds interesting I'll check it out.
Re:RailwayJS by rockyj on Monday October 01, 2012 @03:01AM (#4595698)
I agree. I would do the same but I couldn't find any examples of doing this on the web. One could potentially use Redis or a AMQP as a middleman to integrate node.js's push with a Rails app. If I get sometime on the weekend I would like to try this.
Re:RailwayJS by factorialboy on Monday October 01, 2012 @02:33AM (#4595624)
I'm sorry I don't buy JS code is hard to maintain analogy.

If you write modular and/or functional code, JS code bases can be just as easy / hard to maintain as any other language.

Re:RailwayJS by rockyj on Monday October 01, 2012 @02:46AM (#4595654)
No problem. We can all have different opinions, but the good thing is we are all innovative, experimenting developers :).
Re:RailwayJS by mitjak on Monday October 01, 2012 @03:19AM (#4595740)
Perhaps I'm missing something but how is this a matter of opinion? If one wanted to avoid callbacks, which were the OC's original issue with node, one would break up the callback spaghetti into distinct, possibly prototyped objects, and glue them together with node's events. How is that any more difficult to maintain than, say, Python classes? If anything, I personally like the ability to choose the coding style with JS in this case, e.g. callbacks are great for quick prototyping when you can't be bothered to organize everything properly from the get-go.
Re:RailwayJS by gnufied on Monday October 01, 2012 @06:21AM (#4596118)
In a language like Ruby or Python by using Fibers or Co-Routines(Greenlets), one can get benefit of non-blocking IO at the same time avoiding code spaghetti.

Gevent in python for example is pretty popular and similar is the case with Em-synchony in Ruby.

I have used callback objects but really that is not even close to what one can achieve with Fibers or Greenlets.

Re:RailwayJS by mitjak on Monday October 01, 2012 @10:35AM (#4597193)
Can you give an example? Thanks!
Re:RailwayJS by JPKab on Monday October 01, 2012 @05:48PM (#4599531)
As silly as it sounds, one of my favorite aspects of Node is how ridiculously portable and modular it is. NPM makes everything a breeze, and (thanks to support from Microsoft) it actually allows easy development on Windows. I realize plenty of languages have their own package managers, but NPM is fantastic. The callback aspect definitely requires more discipline, but I'm glad that I've learned it.
Re:RailwayJS by federicoweber on Monday October 01, 2012 @03:41AM (#4595784)
I can not get along with your statement about difficulties to maintain the code. How bad programming can be considered a fault of the language?