What are the use cases of Node.js vs Twisted?
Asked Answered
D

2

67

Assuming a team of developers are equally comfortable with writing Javascript on the server side as they are with Python & Twisted, when is Node.js going to be more appropriate than Twisted (and vice versa)?

Dachy answered 11/8, 2010 at 18:21 Comment(3)
As of 2013 what is the current status of two of these frameworks. Seems more people uses Node.js than Twisted. Correct me if i'm wrongGilges
Make an informed decision and start. – After you passed a couple of issues you know better what to look for to make a better decision. Maybe change your tool and redo it.Interrelate
PyPy has Stackless Python (greenlets a.k.a. coroutines) built in — these are integrated into the Python language and implemented at a deeper level, so thus offer more comfort and better performance over Twisted. but Twisted can also be integrated with it, as well as be made to look more like regular, coroutine based Python code.Adler
U
80

Twisted is more mature -- it's been around for a long, long time, and has so many bells and whistles as to make your head spin (implementations of the fanciest protocols, integration of the reactor with a large variety of other event loops, and so forth).

Node.js is said to be faster (I have not measured it myself) and might perhaps be simpler to use (if you need none of the extra bells and whistles) exactly because those extras aren't there (kind of like Tornado in the Python world -- again, I have never measured relative performance).

So, I'd absolutely use Twisted if I needed any of its extra features or wanted to feel on a more solid ground by using a more mature package. If these considerations don't apply, but top performance is a key goal of the project, then I'd write a simple benchmark (but still representative of at least one or two key performance-need situations for my actual project) in Twisted, Node.js, and Tornado, and do a lot of careful measurement before I decide which way to go overall. "Extra features" (third party extensions and standard library) for Python vs server-side Javascript are also much more abundant, and that might be a key factor if any such extras are needed for the project.

Finally, if none of these issues matter to a specific application scenario, have the development team vote on relative simplicity of the three candidates (Twisted, Node.js, Tornado) in terms of simplicity and familiarity -- any of them will probably be just fine, might as well pick whatever most of the team is most comfortable with!

Unpractical answered 11/8, 2010 at 18:32 Comment(4)
Great answer, and +1 for suggesting the OP look at Twisted (which may be simpler for their needs).Lightyear
An example of node being not quite faster (especially if you use pypy) mrjoes.github.com/2011/12/15/sockjs-bench.html There were other more or less credible benchmarks, but I think a lot of potential performance gains vanish if you use PyPy.Vicegerent
As of 2012, Node.js is pretty mature too :PDextrose
What are these "bells and whistles" that node.js doesn't have?Jude
M
7

As of 2012, Node.js has proved to be a fast, scalable, mature, and widely used platform. Ryan Dahl, creator of Node.js quotes:

These days, Node is being used by a large number of startups and established companies around the world, from Voxer and Uber to Walmart and Microsoft. It’s safe to say that billions of requests are passing through Node every day. As more and more people come to the project, the available third-party modules and extensions grow and increase in quality. Although I was once reserved about recommending it for mission-critical applications, I now heartily recommend Node for even the most demanding server systems.

More formally, the advantages of Node can be classified as:

  • Great community: It can be said that no other platform gained such community appeal in such a short period of time, it has hundreds of contributors and thousands of watchers in GitHub, and is being used by giants like Yahoo! (Manhattan project), e-bay, LinkedIn, Microsoft, and Voxer.

  • NPM: Although having a relatively small core, Node has lots of packages available to extends its functionality to anything you may consider! Its all automated and being developed and extended actively, think of PyPI (pip).

  • Scalability and Speed: Node's architecture and single threaded nature allows high scalability and speed. Specially after 0.8 release, its speed got really faster (benchmarks), which can be confirmed by a lot of large businesses using Node. The V8 core of it is also constantly getting better thanks to the current browser war.

  • JavaScript: The core language of Node (JS) fits better for such server side usages, specially lambda functions, dynamic objects, and easy JSON serialization are JS highlights which really fits well in cases that speed and scalability counts. (Python has all of them but these are really better and more powerful in JS).

  • Deployment: Because of its wide usage, a lot of really good sites provide tools for easy and powerful Node deployment, including: Heroku, Joyent, Cloud9 and a lot more.

Therefore, Node seem more powerful and with a lighter future, so if there isn't any constraint to use it (like existing code, servers, team capability), it is recommended for any new collaborative network project aiming high speed and scalability.

Mcripley answered 27/7, 2012 at 11:14 Comment(10)
It sounds like you're unaware of the extent of Twisted's maturity. None of the points you've highlighted in favor of Node are actually exclusive of Twisted (except for the "JavaScript" point, which is the most tenuous item on the list)!Hourly
@Jean-PaulCalderone well a quick look at the tagstats on the right supports his first point: node.js × 11239 twisted × 1021Whithersoever
If you think that size is the only metric for measuring community, sure.Hourly
Size isn't the only metric, but it is probably the most important.Tactful
Just because there are more question about it, doesn't mean it is less used or have smaller community. Think documentation.Beatific
@Beatific Sure, that was just a sign, not a complete reasoning. Another from 2012 Stack Overflow User Survey Results: "41.2% of programmers are really exited about using Node.js next year", and javascript was by far the most popular language according to the survey. This doesn't prove a larger community either, but...Mcripley
javascript being by far the most popular language is a direct consequence of it being the de-facto language for web client side programming. and again, stack overflow meters don't amount to a popularity of a language or a framework.Beatific
This sounds more like an ads than answering the question, i.e. when the compared framework is more appropriate than the other one.Comminate
Too much hyperbole in this answer IMO. Node.js is not a silver bullet and is not always the best choice for every project. Please consider a more balanced answer providing both pros and cons so the reader can make their own judgementsEchinoderm
I have been developing using both Node (currently) and Twisted (in the past 3 years) and my preference is for the latter. Apart from the fact that Twisted has been around for more than 2 decades, I feel Python to be a much better choice for server side development given a somewhat higher degree of standardization, rich library ecosystem (I am really suffering without Numpy/Scipy) and the fact that Twisted has multi-threading and multi-processing support. As for the speed, I have no benchmark to refer to, but I'd expect Twisted on PyPy to run much faster than Node.Blastomere

© 2022 - 2024 — McMap. All rights reserved.