Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Your main event may be another's side-show.

by BrowserUk (Patriarch)
on Oct 20, 2010 at 01:13 UTC ( [id://866215]=note: print w/replies, xml ) Need Help??


in reply to Re: Your main event may be another's side-show.
in thread Your main event may be another's side-show.

surely there are forking frameworks that are much smaller and easier to use than their big brothers. the reason why the bigger and more complex frameworks exist is because they do a whole lot more than a simple fork, typically allowing all sorts of scheduling and queueing. forking is their primary mechanism, but not their central goal.

That fine if you want everything they do; and if they do everything you want.

But if the former is not true, you have to carry its costs. And if the latter is not true, you are into the game of either waiting for them to provide it, or trying to understand enough of their internals to allow you to wrap over the modules--CPAN or your own--in such a way to make them compatible with the framework.

It all comes down to: Do I call them if and when I need them?

Or: Do I have to try and arrange for them to call me sufficiently frequent that if there is a possibility of there being something to do, I can poll around and see what, if anything, that might be?

(Oh. And then remember to store enough information about what I was currently doing before they interrupted me that I can pick it up when I get back to doing it.)

(Oh. And oh. And not forgetting that if I do find something to do, I'll need to retrieve whatever information I stored last time I was doing it. And then remember to store the modified state once I finished doing what ever it is that I found to do.)

(Always assuming that I succeed in finishing it and don't get interrupted again before then.)

(That's assuming that there was actually something else to do when I got interrupted.)

In a nutshell. Frameworks suck because they force me to work their way for everything. Even when most of the things I need to do aren't a natural fit to that way of working.

On the other hand, the nitty-gritty of forking and IPC can be encapsulated in a way that allows it to be used intuitively and without the need to invert the flow of control, or requiring bending the entire application to the will of the encapsulating module.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^2: Your main event may be another's side-show.

Replies are listed 'Best First'.
Re^3: Your main event may be another's side-show.
by andal (Hermit) on Oct 20, 2010 at 09:13 UTC
    In a nutshell. Frameworks suck because they force me to work their way for everything. Even when most of the things I need to do aren't a natural fit to that way of working.

    Your arguments are too abstract. The framework introduced by certain library is intended to save the time of developing your own framework. So in real life you have the choice of doing everything yourself, or adjusting your work to the ready framework. According to your statement, you just dislike forcing yourself into the ways proposed by others. This is fine, because tastes differ. But in the real life the frameworks created by others can be very helpful. So it is incorrect to simply say "they shouldn't be because I don't like them". There's a saying (at least in Russian) don't spit in the well, one day you may drink water from it :)

      The problems with frameworks start once you need to combine two frameworks. The C++ world suffers greatly from this because every framework implements their own String type for example, and they are all incompatible. In Perl, once you move your application to POE (for example), you'll find you have big problems adding Tk (or even threads).

      There don't even need to be two frameworks. If you have existing code, you likely have to rewrite it to fit the framework you choose, because the target framework wants to call your routines in a specific order (Maypole as an example), or wants a different partition of the program flow (POE as an example). Using threads or Coro can migitate the problem of competition for flow of control by giving the framework its own flow and communicating through messages, but you trade that for a new set of problems.

      The fact that any framework prescribes how to approach a problem is why I prefer libraries (which my code calls) over frameworks (which call my code). I found that in the long run, I'll always end up in corners where I'm working more against the (limitations of the) framework than using it to its advantages.

      See Re^5: Doing an Input->process->Output cycle with AnyEvent? (was: error: "recursive blocking wait detected") for something a little less abstract.

      This really has nothing to do with not wanting to work someone else's way. It's about not wanting to be forced to do everything just one way, because the framework is incompatible with any other way of working. It's about not wanting to give up half the tools in my toolbox in favour of just one. Not being forced to use that hammer to try and saw, plane and drill, as well as drive nails.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        It's about not wanting to be forced to do everything just one way, because the framework is incompatible with any other way of working.

        And that's exactly why I like Coro. The other choices for event-driven development take away extremely useful tools (catching exceptions, stack traces) and pollute every tiny bit of code with the need to write the code much differently. Coro only requires that the exact points where blocking might happen be tweaked to make Coro aware of the blocking and those changes are usually pretty easy to make. The rest of your code shows no evidence of Coro being used.

        Yes, a single Coro instance won't use multiple cores. That has never been an issue in the projects I've considered Coro for because either they need to scale so I plan on running multiple instances anyway or they don't in which case one core is enough and the other core(s) get used by other stuff. Yes, there are cases where you don't want multiple instances and yet do want to use multiple cores but don't need more cores than are in the one computer you are using, and Coro would not be the best choice in such a constrained situation.

        I find that threading can be very useful in the simplest of cases. But having spent years writing multi-threaded code with a group of people who were very good at it, I believe that scaling via threading is nearly a doomed endeavor. My experience is that the vast majority of programmers are quite bad at identifying race conditions. They are even worse at preventing race conditions. And they are worse still at both of those tasks when threads are involved. And even the best programmers can't keep a long-lived, significantly upgraded system free of serious problems associated with using threads.

        IME, I'm pretty good at those tasks. And I'd still rather just avoid dealing with them as much as possible. Adding real threads (not what Perl 5 currently calls "threads") means that you have race conditions to consider all over the place. Perl's "threads" came to be because no Perl porter was able to remove the race conditions from trying to use real threads with Perl. So they switched to using threads to emulate fork() but much less efficiently in both memory and CPU required. So I prefer real fork over emulated fork. On Windows, I tend to either use cygwin or use spawn to emulate fork.

        I've not used Perl "threads" under Windows even for simple tasks because every time I've tried I've found bugs almost immediately. Lots of people say that is no longer going to happen but then they said that lots of previous times when I still found bugs almost immediately.

        I consider Perl "threads" under Windows for simple tasks and so will likely try again at some point. But I strongly avoid threads in a project that will need to scale either to running many instances or (more importantly) to having an extended lifespan of active development and enhancement.

        And I've seen many projects start out just fine using threads and then have an ever-increasing set of problems with race conditions, deadlocks, and lack of concurrency. And those problems are rather fundamental.

        I'd love to see a very general-purpose framework for preventing race conditions that also prevents deadlocks and reduced concurrency. I don't think one has been invented yet other than the very successful framework of a preemptive-multitasking operating system using processes with segregated resources. When the overhead per process becomes a problem (as can happen with Perl), I think coroutines present the best available long-term solution by allowing one process and one Perl interpreter to handle a large number of simultaneous tasks with only minimal coroutine-specific code. And it looks like Coro is a good implementation of coroutines for Perl.

        - tye        

        this is dejavu my little rant about PHP becoming so popular when PHP became loaded with properly unified frameworks as part of the standard stack. CPAN was great at the start to encourage experimentation and helping others, in the Open Source fashion. perhaps perl needs a similar thing to be revived. it's still a great language, but modules/frameworks and so many variants, are also detriments to mainstream takeup. Lately i'm seeing servers with perl 5.6, left un-upgraded, because there's too much effort needed in upgrading it and all the modules etc..and they still do their rudimentary perl tasks as quiet achievers.
        the hardest line to type correctly is: stty erase ^H
        This really has nothing to do with not wanting to work someone else's way. It's about not wanting to be forced to do everything just one way, because the framework is incompatible with any other way of working. It's about not wanting to give up half the tools in my toolbox in favour of just one. Not being forced to use that hammer to try and saw, plane and drill, as well as drive nails.

        Let's be precise. If you just don't like some introduced frameworks then it makes sense to talk about those frameworks and not about frameworks in general. And really, frameworks don't force to do everything their way. After all, you have the full right to create the whole Xwindows from scratch using your own idea how it should work. But you don't, because in real life you can't. So the existing framework is GOOD thing. It saves you lots of work. As a payment for having good thing you should do much smaller work of adjusting your needs to that existing framework. And if you think a little, then usually you can find fairly easy way to join 2 different frameworks. For example, event driven application can nicely coexist with threads or other processes. They just should communicate using pipes.

Re^3: Your main event may be another's side-show.
by aquarium (Curate) on Oct 20, 2010 at 02:06 UTC
    don't get me wrong. i agree that some (maybe most) have a lot of bloat etc. in the end it's up to you to decide if/when/how to use a fork framework. i guess a lot of typical problems involve pre-forking daemon process(es) with a central queue mechanism and such. and hence these more complicated frameworks proliferate. it certainly would be nice to have a very minimal forking wrapper, with a nice fork function that takes care of the tiny details (handling process initiation and termination, and which signals to use etc), and nothing else.
    the hardest line to type correctly is: stty erase ^H

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://866215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-19 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found