Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: Plack Middleware aXML

by Logicus
on Oct 20, 2011 at 11:58 UTC ( #932637=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^5: Plack Middleware aXML
Download Code
Re^6: Plack Middleware aXML
by Anonymous Monk on Oct 20, 2011 at 12:04 UTC

    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?

        It uses a smaller number of characters. Next question

        That really isn't sufficient, maybe if you had strict/warnings

Re^6: Plack Middleware aXML
by Jenda (Abbot) on Oct 20, 2011 at 13:11 UTC
    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); };

    Jenda
    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.

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

        That's not a fair comparison, for several reasons:

        • SLOC isn't an interesting metric until you get to orders of magnitude difference
        • Comparing a framework to something at a different abstraction level is misleading
        • There's running Perl code behind the aXML example that looks much like the eventual Perl code someone would have to write anyway
        • SLOC isn't the only meaningful concern. Consider syntax checking or highlighting, or debugging, or testing. The Perl infrastructure and toolchain has quite a few advantages over aXML due to its maturity

        I'm not saying aXML lacks its advantages, but concision alone isn't such a meaningful metric.

        Also your example Perl 5 code has a security hole. (We've talked about this before.)


        Improve your skills with Modern Perl: the free book.

        There's no way to reimplement your example as there's no way to understand what the heck is the magic incantation supposed to do. On the other hand if instead of aXML "plugins" you simply implemented the same number of functions I'm pretty sure you could call them by code that'd be about as long, if not shorter, as your aXML example.

        See ... you do not have to write all your code using the modules you got with Perl or downloaded from CPAN. You can write your own, more specialized and higher level modules and then ... instead of using Plack::Request and DBI directly, you just call the functions or methods from those modules.

        If instead of fiddling with the aXML engine and writing aXML plugins, you wrote prettymuch the same thing you've put into the plugins as a plain old module, you could write Perl code at exactly the same level of abstraction.

        And then the way to add the AJAX chat you boast about in your later post would be

        AJAXchat("path/to/storefile");

        If you want a fair comparison at least for the simplistic "dump if debugging" example include in your SLOC the definitions of the debug and dump aXML plugins and then compare that with my code. Or compare your (debug)<dump>$env->{'psgix.session'}</dump>(/debug) with it's pure Perl counterpart debug { Dump($env->{'psgix.session'}) };.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (16)
As of 2014-08-22 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (163 votes), past polls