

Node.js modules you should know about: socket.io - pkrumins
http://www.catonmat.net/blog/nodejs-modules-socketio/

======
jinushaun
I do a lot of real time stuff, so socket.io is my favorite node.js module. It
makes sockets so easy to use that I now use socket.io sockets (instead of
regular sockets) for everything, which causes a problem because of lack of
support for WebSockets outside of the browser. For example, connecting to a
socket.io server from Android using Java. Fortunately, forked some code on
GitHub (<https://github.com/benkay/java-socket.io.client>) and got it to work.

------
hello_moto
Got a question to y'all regarding the whole node.js stuff.

I downloaded ExpressJS framework and tried to create a simple MVC apps a'la
Rails...

I get the impression that ExpressJS framework works better if you put the
whole thing in app.js. Like... the whole code.

I tried to create another file other than index.js inside routes folder (let's
call it something.js) so I can instantiate some JS controller code in app.js
vs putting everything in one file. That doesn't work at all, "something" is
undefined.

It turned out that I have to either put everything in app.js or in
routes/index.js in order for ExpressJS to work correctly.

The whole experienced was... unexpected.

I'm kind of used to Rails MVC. So please tell me: am I using ExpressJS the way
it shouldn't be used?

UPDATE: Thanks for the answers guys. Kind of what I would have guessed to hear
=> use module. Which is probably fine. Module in CommonJS does have a bit of
bookkeeping beforehand.

I did have a bit of a hunch that I needed to know more about CommonJS and
proper modern JS practices.

~~~
chapel
Express is very flexible, and can work in just about any way you could
imagine. Take no offense but it sounds like you aren't very familiar with
javascript or node.js and that is okay, but there is much to learn about
project organization.

It is actually quite easy to organize your code similar to a rails mvc
application, the key is being consistent.

If you want to see a working example of an mvc style express application, then
look at the examples provided with express:
[https://github.com/visionmedia/express/tree/master/examples/...](https://github.com/visionmedia/express/tree/master/examples/mvc)

Again, there are many ways to organize your applications, just look around at
what other people have done, or use the examples, and you should be able to
make yours handle just the same.

~~~
Vitaly
This is one of the things that Rails gets right. There is no real need to be
creative here. Rails just comes with a default layout built in, no need to
'choose your own' for the 'own' sake. It doesn't, btw, mean that you can't use
your own, just in this case you'll need to add the relevant directories to the
path yourself. The standard layout and built in generators are just brilliant.

~~~
chapel
Of course it is a matter of opinion, but you have to keep in mind that node
itself isn't a framework like rails, and express while similar to sinatra with
declaring routes is very un-opinionated about how it handles things. That is
one reason I enjoy using node and a lot of the modules and add-ons created for
node, giving me the freedom to do what I want from the start and not fight
against the 'right' way the creators intended.

~~~
Vitaly
this is a common misconception about rails.

Rails doesn't "force" you to use their way. You don't have to call your table
"people" if your model is called "person". It just that you have _additional_
freedom not to configure anything if you are ok with the default
configuration.

in many other frameworks you _always_ have to configure _everything_ , abut in
rails you might just go with the defaults and skip the configuration
altogether.

If express had code generators that would generate standard layout for models
etc it wouldn't hurt anyones' ability to use their custom layout.

------
drewda
Can anyone comment on how Socket.io and Faye* compare?

* <http://faye.jcoglan.com/>

~~~
dwynings
[http://stackoverflow.com/questions/4893720/faye-vs-socket-
io...](http://stackoverflow.com/questions/4893720/faye-vs-socket-io-and-
juggernaut)

------
untog
The only thing that disappoints me about socket.io is that the client library
is 40KB- I'm developing a mobile app and am trying to keep JS memory usage to
a minimum (ZeptoJS instead of jQuery, etc) and socket.io's client lib is just
so huge.

Is there a stripped down version of it, or some other wrapper library around
websockets? I've been playing with just using the native stuff, but the
different versions of API implementation are biting me a little.

