in reply to AJAX popup windows - an example
Perhaps your tutorial could deal with issues such as:
- how to serve standard RPC wire-formats (JSON, SOAP, REST) in Perl,
- some of the animation effects provided by modern JS/Ajax toolkits to improve the popup/tooltip presentation.
|Replies are listed 'Best First'.|
Re^2: AJAX popup windows - an example
by snowhare (Friar) on Sep 16, 2007 at 13:09 UTC
Don't take what I'm about to write as disagreeing with you. It is more about the thought process that went into my choice to use CGI::Ajax for the example. Your points are strong, although possibly not complete: You've validly pointed out that clarity and 'non-intrusiveness' suffers in my example. What you missed is that it traded it for performance.
Not really. You see, performance and size tend to be my primary goals because I frequently need these kinds of scripts to be used on web pages that both receive many hits per day and that are already overly heavy byte-wise.
So my goals of "runs fast, loads fast" compromised with the goals of "code clarity, full featured" to settle on CGI::Ajax for the example to get "Ajax clarity, acceptable performance".
Code clarity would have argued for using one of the major JS toolkits. Performance would have argued for eliminating CGI::Ajax entirely and not using a toolkit library.
Similiar issues arise using the off-the-shelf Ajax libraries. They add dozens to hundreds of Kbytes of stuff needing to be loaded by the web browser (with dramatic performance consequences resulting just from that fact). Additionally, they tend to run slowly above and beyond that (Digg is a classic example - they use an off-the-shelf JS Ajax library that causes my machine to bog completely down on their longer pages. It is quite annoying.)
So, in addition to your (excellent) suggestion of covering the use of off-the-shelf Ajax JS libraries, I need to cover when-and-why NOT to use them.
Class::Accessor is included out of laziness - not having to code setters/getters for objects.
As we all know, laziness is one of the virtues of a perl programmer, so that seems OK. But it isn't, because it conflicts with hubris, which beats laziness for Module authors. You don't want anybody to ever say something bad about your module, do you?
Data::Dumper is a leftover from development. It isn't used anywhere in that module. And that one pulls in:
Then there's the ubiquitous 'vars' module, which does
A little bit of (crude *) cleanup to the header of CGI::Ajax
and all dependencies are eliminated
Of course the code using CGI::Ajax might pull in Exporter, scrict, warnings, vars et al anyways - but it is not CGI::Ajax's business to do so if it can do without.
OTOH, if the code that uses CGI::Ajax uses all those modules anyways, it is better to have them imported once instead of compiling duplicated code. So the cleanest thing would be adding a conditional in a BEGIN block, and pulling in Class::Accessor et cetera only if those namespaces are already present, because the cost of linking in already loaded modules is close to nil.
But then, this would depend on module loading order... not doing so for this particular module would just add 15 lines of code (which doesn't say much about perl's internal waste thereof... :-)
*)I just dumped the methods mk_accessors() generates and stuck them into the BEGIN block. Works.
update: corrected bug in set/get constructor
Speed.The reason that I don't have any speed issues with my HTML user interfaces is that, from perl's perspective, my user interfaces consist entirely of static HTML (which is nicely cached by the web server). perl code doesn't serve that HTML at all (with the exception of some mod_perl-based authentication handlers).
Dynamism.It may be heretical to some folks here, but I think templating is fine for web content, not so much for exposing web application functionality. The more complicated or multi-faceted a user interface the more convoluted templates become, often with the outcome that the templates don't serve their initial goals - to uncouple viewables from code (for clarity), and to make visual assets separately maintainable.
I still like the idea of using templates to frame the overall look and feel of a site.
Functionality.Nowadays, it's possible to have fast, semantically concise, intuitive, attractive user interfaces provided in a cross-platform manner in a variety of technologies.
None of those technologies requires the authors of client-side user interfaces to move to completely homogeneous implementations; the technologies can be separately embedded in HTML and combined to interesting effect.
Updated: added a bit more detail in to clarify some points.
Re^2: AJAX popup windows - an example
by shmem (Chancellor) on Sep 16, 2007 at 07:07 UTC
No module ever claimed to Do It All For You, except perhaps some module from the Acme namespace.
CGI::Ajax does a specific task, and it does it pretty damn well and in a KISS way. Of course it is not good-for-all and constrains you in e.g. always passing a parameter fname for the perl function callback in the XHTTP query, but then fully-fledged Ajax Toolkits aren't any different: they put you on rails.
CGI::Ajax is a very good example of a 'module at its best': it solves a particular problem without getting too over-featured and provides a nice wheel that hasn't evolved into a monster truck. <update> Although it has some issues. See my follow-up below. </update>