Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^4: Plack Middleware aXML

by Jenda (Abbot)
on Oct 20, 2011 at 09:26 UTC ( #932594=note: print w/replies, xml ) Need Help??

in reply to Re^3: Plack Middleware aXML
in thread Plack Middleware aXML

If you've cooked the pudding for yourself, then yes, the proof is in the eating. If you've cooked it for others, then the proof is in the selling. You've failed to sell even the idea of a pudding.

So it's possible you've learned to cook ... at least so that you yourself like what you cooked ... now comes the (for you apparently much harder) problem of learning to advertise and sell.

Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^5: Plack Middleware aXML
by Logicus on Oct 20, 2011 at 11:58 UTC

    I never was any good at sales or salesmanship, that is probably why I'm in the opensource arena. All I can do is describe what the thing does, what I believe its advantages to be and to provide a download for people to give a whirl themselves. Said download will not be long, however if not long is too long, then the principle of the thing is basically exactly the same as previous releases, this version is just a shed load faster.

    Now it's fair enough to say that the original was far too slow for a large scale site, but do bear in mind that I was using it for various apps for over 4 years without any problems or even any pressing desire to upgrade it or change it in any radical way. Maybe that tells you something, maybe not.

    All I know is that when the new version is as stable and reliable as the old version, my development time will be just about 100% devoted to making cool sites on top of it rather than fiddling around with the guts of the thing. It was a rare event that I felt any need to look lower than the document level and usually when I did so I came to realise that the error was in the document and not in the system or its plugins.

    like I said I'm not a salesman, I'm a geek and an inventor and I'm not the best at social situations generally even when people haven't already decided they love to hate me.

    perhaps a little example of some code would help here

    In aXML I can go : (debug)<dump>$env->{'psgix.session'}</dump>(/debug) And this, because of the code of the plugins "dump" and "debug" is equivalent to : if ($debug) { my $dump = Dumper($env->{'psgix.session'}); $dump =~ s/\n/<br>/gs; print $dump; }

    So you see it's a lot simpler and quicker, and less prone to bugs and typos, and easy to understand / reuse. My main template for the site I'm working on right now has that line in at the bottom, and the $debug var is set from the Conf file, so I can then just turn the debug output off and on from there.

    The only limit on the abstractions is your imagination... for instance, who knows what <splarg> does... infact you can choose what it does by writing a plugin called splarg. You can overload any existing abstraction with your own, you can change the meaning of abstractions on the fly during the rendering time... the possibilities are endless, and I'm not trying to suggest that the abstractions I've come up with represent a complete set or are even the best ones to use it with... indeed I hope that eventually others will come with new and cool things I haven't thought of that make working life with it even more fun and interesting.

      All I can do is describe what the thing does, what I believe its advantages to be

      But that's exactly what you FAILED to do!

      use Data::Dumper qw(Dumper); $main::DEBUG = 1; sub debug (&) { if ($main::DEBUG) { $_[0]->(); } } sub Dump { my $dump = Dumper($_[0]); $dump =~ s/\n/<br>\n/gs; print $dump; } debug { Dump(\%ENV); };

      Enoch was right!
      Enjoy the last years of Rome.

        You looking at it with a bias that you seem unaware of, whilst I agree the above example is a very nice neat bit of masters Perl, it is beyond the understanding level of the target user base.

        My plan is and always was to make good structure easy and implicit, such that cheap spaghetti brained code monkeys who find things like PHP to be a challenge to the upper level of their intellectual capacity, can produce well structured and reusable apps quicker and easier than they can using things like PHP.

        If they then graduate onto the level of writing plugins good for them, if they then continue to grow as a programmer and learn enough to write masters Perl, good for them and good for Perl. Most of them will never attain that level, the vast majority will do exactly what they are doing now, cutting and pasting code with very little understanding of what they are actually doing or why the spaghetti messes they make are bad.

        You can golf your code down as much as you like and marvel at how few keystrokes your using, but as soon as you use 'magic' symbolism in there, you've just lost most of the audience.

        There is a reason why Master Perl programmers earn upwards of 60,000 a year; they are in short supply because most programmers are not smart enough to reach that level.

        There is a very good reason why Larry is so keen on allowing for Baby perl to exist without being punished, it's because he knows that not only is today's baby perler potentially tommorrows master, but also that the distribution curve of IQ points in the population means that baby perlers will always outnumber masters by many to one, and failing to support them in favour of top end people capable of writing things like your example, is a surefire way to end up with a language only intellectuals like us can appreciate.

        There will always be a 1 : 1 mapping of aXML code to perl code, because aXML is written in Perl. And the perl code will always be both more efficient and flexible, provided that the programmer has sufficient understanding of the language to use and debug it. For the same reasons that their will always be a 1 : 1 mapping of Perl code to C code, and a programmer capable of writing the Code in C will also gain in terms of efficiency and flexibility. Its as true to say that only aXML can parse aXML as it is to say that only Perl can parse Perl, and for the same reasons!

        Another thing is that the example I gave was just to illustrate how the structure works, the system is not intended to be a replacement for the syntax of perl, but to be complimentary too it.

        It would be interesting to see just how many lines of Perl you need to trigger the same functionality as this example:

        <batchvalidate> <test rule="username_not_taken" username="<qd>username</qd>" > [mem ref="username_error"]1[/mem] </test> <success> [use]adduser[/use] <success> <failure> [use]signup[/use] </failure> </batchvalidate>

        Where there can be multiple tests, and the example connects to the database, checks if the username exists in the users table, and then decides what to do based on the results.

        I would suggest the equivalent Perl code, if given in it's entirety like your example would be something like this;

        use Plack::Request; use DBI; use Conf; use Modern::Perl; my $env = shift; my $qd = $req->parameters->mixed; my $dbh = DBI->connect( $Conf::conf->{'dsn'}, $Conf::conf->{'dsn_username'}, $Conf::conf->{'dsn_password'} ) || die "Could not connect to database: $DBI::errstr"; my $sth = $dbh->prepare(qq@ SELECT count(1) FROM users WHERE username="$qd->{'username'}" @); $sth->execute; .... ....

        Blah I can't even be bothered finishing this example, if you don't get the point I'm making then maybe you never will.

      So you see it's a lot simpler and quicker, and less prone to bugs and typos, and easy to understand / reuse.

      How is it less prone to typos?

        It uses a smaller number of characters. Next question?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932594]
[erix]: Makefile.PL should tell me, probably

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-06-22 16:48 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (524 votes). Check out past polls.