Live data from Hacker News

The Twisted Way

glyph.twistedmatrix.com

11–20 of 32 posts

Re: The Twisted Way

#11
post #10

GREAT SOLUTIONS IN ENGINEERING Problem: bicycle seats are hard. They hurt. Analysis: there must be something wrong with your pants. "Solution": dorky pants. from http://dilbert.com/strips/comic/1994-07-18/ Problem: Python has poor support for threads, and concurrency in general. Analysis: you must need more middleware. "Solution": incomprehensible callback-based frameworks.

If by incomprehensible, you mean you need to read more than 10 pages of documentation to understand it, then sure.

Re: The Twisted Way

#12
post #11
post #10

GREAT SOLUTIONS IN ENGINEERING Problem: bicycle seats are hard. They hurt. Analysis: there must be something wrong with your pants. "Solution": dorky pants. from http://dilbert.com/strips/comic/1994-07-18/ Problem: Python has poor support for threads, and concurrency in general. Analysis: you must need more middleware. "Solution": incomprehensible callback-based frameworks.

If by incomprehensible, you mean you need to read more than 10 pages of documentation to understand it, then sure.

There are two problems with callback based frameworks.

#1 In python specifically, we do not have proper closure and no anonymous blocks, this makes operating it tedious as the definition of the logic for a callback is always somewhere else from where the callback is setup.

#2 In any language supporting proper closures (javascript for instance, hello node.js) excessive, nested use of callback based frameworks leads to the phenomenon of the pyramid of death, whereas you keep nesting closures and you have to keep them all in one place because each depends on its outer scope.

I intently dislike twisted and node.js for these very reasons. I've written my own little framework based entirely on greenlets in python, which is delightful and easy to use and entirely avoids both dislocality of action and the pyramid of death.

Re: The Twisted Way

#13
I've used twisted for semi-major project (https://github.com/Yelp/Tron).

It's certainly a difficult thing to get your head around. The parts of the project that touch twisted is always the most complex to explain to anyone else. However, async code is always hard. It also doesn't help that the code base shows it's age.. non-PEP8, strange naming conventions etc.

However, one thing that I've noticed with recent projects using Tornado (https://github.com/rhettg/Dynochemy) is that some concepts that I thought was overly complex in Twisted makes sense eventually. For example, handling errors in async code is really hard. The framework twisted came up with with Deferred, callbacks and errbacks is pretty smart. You almost have to re-invent twisted before you can appreciate it.

I'd recommend reading the original paper for more information: http://www6.uniovi.es/python/pycon/papers/deferex/

Re: The Twisted Way

#14
Twisted is great. The only real problem comes from their utter unwillingness to accept less-than-100%-perfect ipv6 patches. It's 2012 for fuck's sake.

Re: The Twisted Way

#15
post #11
post #10

GREAT SOLUTIONS IN ENGINEERING Problem: bicycle seats are hard. They hurt. Analysis: there must be something wrong with your pants. "Solution": dorky pants. from http://dilbert.com/strips/comic/1994-07-18/ Problem: Python has poor support for threads, and concurrency in general. Analysis: you must need more middleware. "Solution": incomprehensible callback-based frameworks.

If by incomprehensible, you mean you need to read more than 10 pages of documentation to understand it, then sure.

Callbacks are bad for the same reason non-local gotos are bad. They destroy locality and make the code hard to read.

Re: The Twisted Way

#17
post #12
post #11

Earlier quoted context omitted.

If by incomprehensible, you mean you need to read more than 10 pages of documentation to understand it, then sure.

There are two problems with callback based frameworks. #1 In python specifically, we do not have proper closure and no anonymous blocks, this makes operating it tedious as the definition of the logic for a callback is always somewhere else from where the callback is setup. #2 In any language supporting proper closures (javascript for instance, hello node.js) excessive, nested use of callback based frameworks leads to…

What do you mean by greenlets?

Twisted feels to me like a grand experiment that's groping towards something that we know is there, but not quite catching it yet. I guess I/O monads feel like slightly further along the path - but they're still not the true solution. What does your system look like?

Re: The Twisted Way

#19
post #3

Twisted is the least accessible of the big Python libraries that I've come across. I've come to it a couple of times when it seemed like it would suit a problem I had, only to throw up my hands in frustration and go look for a solution somewhere else. Unfortunately this article did nothing to enlighten me - it has some pretensions of being philosophical without explaining any of the practicalities. Does anyone use Tw…

Yes, I use Twisted in production. I absolutely consider it worth the learning curve. And I've started new projects in it in the last 3 weeks, so I guess that answers your final question.

Re: The Twisted Way

#20
post #3

Twisted is the least accessible of the big Python libraries that I've come across. I've come to it a couple of times when it seemed like it would suit a problem I had, only to throw up my hands in frustration and go look for a solution somewhere else. Unfortunately this article did nothing to enlighten me - it has some pretensions of being philosophical without explaining any of the practicalities. Does anyone use Tw…

[deleted]
Post reply on HN