Answer the question
In order to leave comments, you need to log in
What technologies to choose for writing a chat?
Hello!
I have a web application written in Rails. In the near future, its development is planned - the development of a mobile application in addition to the API, which will also be in Ruby.
One of the new features of the service is a chat in which users can communicate both from the web interface and from the mobile application.
What would you use to write such a chat and why? I look with interest at Clojure, Erlang, Node.js
Answer the question
In order to leave comments, you need to log in
Erlang to the rescue. It is because of ejabberd. A good well-established solution for which JavaScript chat is also written. That does not preclude the use of desktop clients. IMHO, it turns out quite flexible + enough regardless of the main application.
PS Yandex chose erlang in due time;)
Everything is very simple. Take a websphere application server, set up apache active mq there and deploy an enterprise project.
An example of chat on WebSockets under Erlang:
event(chat) -> wf:send(chat, wf:q(message)),
body() ->
wf:async(fun() -> loop() end,chat),
[ #panel{id=history}, #textbox{id=message}, #button{postback=chat}].
loop() ->
receive
Message ->
wf:insert_bottom(history, #span{text=Message}),
wf:flush()
end,
loop().
For node.js, there is such a wonderful thing as Socket.io (there is an implementation in Erlang) - a client-server library.
I would choose Node.JS. Very easy to develop. As a demo, they originally made a chat. You can see here . Source code is attached.
If you're a hardened rubyist, you should implement a server based on
faye/faye-websocket-ruby or imanel/websocket-ruby with workers on sidekiq . As an environment, I personally prefer JRuby. I also saw people running ruby sock.js . I can't even imagine why its popularity is lower than the same socket.io, and its support is many times better.
You also need to write fallback on Server-sent events and long polling.
Although you can generally not bother with websockets - it may be enough, and for chats with a large number of people, its performance will be higher than that of Websockets.
And so, in a neighboring universe, I usually use Vert.x and local sock.js with a fallback to sse.
If you need a fast yet productive solution, check out anycable. This is a reworked rail action cable in golang, which is easily integrated into rails, replacing the action cable. As a result, you use all the goodies of the ruby world and at the same time have the performance of golang under the hood.
https://anycable.io/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question