Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

IO::Lambda - suggestions wanted

by dk (Chaplain)
on Jul 08, 2008 at 08:05 UTC ( #696171=perlmeditation: print w/ replies, xml ) Need Help??

Hello Monks,

I am writing a yet another async IO framework for perl, this time I humbly think it's a bit more interesting than anything else, something different from the usual combination of objects and callbacks.

I should very much like to ask those of you who use IO, preferably async IO, in perl, to take a look at the module with a critical eye, because I feel that there should be room for improvement, namely, implementation of features and uses that I haven't thought of. The suggestions I'd be most interested in would be new uses of the framework - of any kind, real or imaginary. New classes and/or protocols - right now there's support for http, https, dns, and snmp, and I am of course aware that there are more, I just don't want to spend time implementing a protocol that no one needs. The examples of use, - if the existing ones aren't straightforward enough, I can't estimate that myself. Finally, the language - I'm not a native speaker, so I can't really judge if there are any lame phrases. But really, any suggestions are welcome.

The module name is IO::Lambda. The idea behind it is to minimize the amount of programming required for async IO, and use better syntax. I think I succeeded here more or less, and that could especially be seen when using the module for programming complex protocols and state machines, not just for one or two callbacks. I deliberately don't give any example code here, and don't go further with the description, because I don't what it to spoil the first impression from the module documentation itself. However, I can write a separate, longer article, with examples and meditations and what not, if anyone would be interested.

Comment on IO::Lambda - suggestions wanted
Re: IO::Lambda - suggestions wanted
by Joost (Canon) on Jul 08, 2008 at 20:03 UTC
    Looks nice. I should look at it a bit further.

    One thing that immediately jumps out at me as confusing, though, is the use of the word "lambda" as a constructor (or whatever it is it does). It's really confusing to Lisp programmers. (That, and lambda is just a really hard word to type on a QWERTY keyboard - I don't even like to use it much in Lisp).

    Also: any benchmarks, or just a general indication of the framework's structure WRT overhead etc? Currently, I would probably consider a considerable speed differences a deal maker or breaker when choosing an async IO framework.

      You're right, there's no benchmarks, thanks for the tip, I'll go for that. As for the lambda, it seemed somewhat natural for me back then - anonymous callback bound to IO... OTOH there would be no problem to make the lambda keyword an alias to another, less confusing name, so the only question is what that name should be? new_io_chain ? Doesn't sound... don't know really.

      update: here's some premature benchmarks. the source code will be added to the next release, for now it's here

      Single-process tcp client and server; server echoes back everything is sent by the client. 500 connections sequentially created, instructed to send a single line to the server, and destroyed.

                              2.4GHz x86-64 linux
        Lambda using select       0.694 sec
        Lambda using AnyEvent     0.684 sec
        Raw sockets using select  0.145 sec
        POE using select          5.349 sec
      
      the POE numbers are somewhat strange. I might've done something wrong there, anyone interested is welcome to check tcp-poe.pl from the link above.

        Why not aio (asynchronous/anonymous i/o) or simply io? It's all about I/O, not about the particular construct (a lambda), right? A couple of examples rewritten with the new keyword:

        my $q = io { print "Hello world!\n" }; $q->wait; $q = io { context io { 2 }, io { 3 }; tails { sort @_ }; }; print $q->wait;

        Of course, you would need to rename the current io predicate to something else; perhaps io_trigger?

        I also suggest moving the Stream I/O section near the beginning of the documentation file. Yes, the mathematically logical order is to introduce low-level things first, then define high-level things using them, but my interest was only sparked after reading the Stream I/O section. Unfortunately it's at the bottom, and I suspect many people will stop reading or browsing before reaching it.

        Alternatively, move the high-level examples to the synopsis before the low-level ones. The low-level examples are mostly toy examples. If you can't think of any better ones right now, remove them. For instance, why would I want to create a "pipeline that waits for 2 lambdas"?

        --
        print "Just Another Perl Adept\n";

Re: IO::Lambda - suggestions wanted
by Zen (Deacon) on Jul 08, 2008 at 21:42 UTC
    I also question the Lambda word. I recommend something more descriptive.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://696171]
Approved by Corion
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2014-08-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (118 votes), past polls