Socket.IO vs. Twisted [closed]

2019-04-28 13:53发布

My idea is to build a simple chat application for iOS and Android. In any case, my question is related to the server-side. The best option to do a chat application, from what I've read, is to build a socket. Referring to the database, my intention is to use MySQL, which may also be important to take into account in order to choose one of the possibilities.

My question is, in terms of scalability, speed and security, which is the best option: building a socket with Python using Twisted or with NodeJS using Socket.IO?

I guess that there may be other possibilities to build an efficient socket, but by now I'm considering this two. I'd really appreciate it if you could give me some advice.

1条回答
做个烂人
2楼-- · 2019-04-28 14:34

Comparing Twisted and Socket.io is comparing apples to a truck carrying apples. Twisted is a library that provides event oriented programming functionality to Python. In javascript that's merely javascript itself (be it node.js or a web browser or even rhino).

A more apt comparison is to compare Socket.io on node.js with Socket.io on Python. While there is one main implementation of a socket.io server on node there are several for Python:

(taken from the socket.io wiki: https://github.com/learnboost/socket.io/wiki)

You can even implement your own socket.io in Python using Twisted if you want. The socket.io protocol is documented here: https://github.com/LearnBoost/socket.io-spec. But that would defeat the purpose of socket.io - it abstracts away low level details of real time web communications and allows you to concentrate on writing your business logic.

On the client side you'd deploy the same socket.io script to the browser regardless of what language you decide to write the server in.

With regards to which language to choose: my rule of thumb is choose the language you're most comfortable with. You're going to have enough problems debugging your business logic. Don't complicate it by using an unfamiliar language.

Both languages are battle hardened (yes, even node.js which is surprising considering how young it is). Python for example is used in production on such high traffic services as Dropbox. Node is currently in use on such high traffic services as LinkedIn mobile.

查看更多
登录 后发表回答