On Sunday, March 2, 2014 7:49:44 AM UTC-5, Gurpreet Luthra wrote:
socket implementations ? Are there things out there already ? Does it make
For more options, visit https://groups.google.com/groups/opt_out.
Gurpreet’s response is accurate, but I think I would add a few things.
know Rails pretty well, but I’m just learning node.js. while it’s true
that you can write blocking (synchronous) or non-blocking (asynchronous)
code in either language, Ruby is primarily a blocking language while
relatively simple statements to open a file and read the contents of the
[Open file statement]
[Read file contents statement]
By default, if you run this in Ruby, you will get what you expect. It
the command to the operating system to open the file, then attempt to
the contents whether the file has finished opening or not. In
you have to program the second statement as a function callback to the
You can write this asynchronously in Ruby, but that’s not the default.
library which will operate synchronously, but you have to consciously
Therefore, I still find node.js easier to use for asynchronous chaining.
However, it would not meet my needs for an overall web application
development framework. It is nowhere near as strong as rails (e.g.,
routing in node.js is much more work), even with frameworks such as
express.js and templating engines. The other thing you have to watch is
that there is absolutely no concurrency in node.js and you wouldn’t want
use it for heavy calculations. Rails also has much broader support for
kinds of things through gems. The npm library (the node.js equivalent)
nowhere close to being as robust and it is, again, a pain. Managing
dependencies with the Ruby bundler is way easier than node.js.
is much more established in Rails, where node.js requires configuration.
My goal is to be able to use the two together (I’m not close to that
I would like to do web application development in Rails and use node.js
for Ajax calls, particularly straightforward calls such as basic create,
update, and delete operations and things like web socket pushing of
information in json format.
With respect to web sockets, I don’t work with it much because support
Internet Explorer and Android is relatively recent and older versions of
both browsers are still in use with a considerable number of users. My
applications also typically don’t have a need for that type of push
communication. I can tell you that node.js does have fairly robust
through socket.IO. The nice thing about socket.IO is that it kind of
abstracts the bidirectional communication issue. It tests for websocket
support. If it doesn’t exist, it uses older polling methods. You don’t
really have to worry about it. To be honest, I haven’t really pursued
socket support in Ruby so I’m not sure what the options are or how
complicated it is.
sorry if this was a little long, but I hope it answers your question.