in reply to Tk-esque ajax libraries

I fear its a "bridge too far".

I believe this has been occasionally mentioned on the ptk list/newsgroup. A similar project was started sometime ago to provide a Tk-like API for XUL, but it never went anywhere.

It would be nice to take all those Tk apps, flip a switch, and make them run under insert favorite webserver/framework here. But pTk tends to encourage a tight coupling between View and Model that may not map well to the loose coupling required between the browser running JS and the server running Perl. Assuming that much of the mapping needs to run in the browser, the API may not port very well into Javascript.

That said, it might be possible to create a Tk-like API in Javascript, and then add some sort of preprocessor/template system to convert the various closure and tied variable interfaces into XHR driven equivalents. The exersize will certainly give you a significant appreciation of the efforts of the late great Nick Ing-Simmons.

Whether or not carrying forward such an API is a good idea is debatable...OTOH, any consistent API for AJAX widgets would be a godsend. Perhaps some extensions to HTML::Widget would be a better solution ?

Replies are listed 'Best First'.
Re^2: Tk-esque ajax libraries
by f00li5h (Chaplain) on Nov 01, 2006 at 11:21 UTC

    renodino, does make some excelent, and somewhat disheartening points, which I've taken the liberty of mangling and answering (perhaps) below:

    pTk tends to encourage a tight coupling between View and Model that may not map well to the loose coupling required between the browser running JS

    In order to manipulate the widgits the request would need to contain some javscript - which could get a little hairy. I was going to (to start anway) just map every single onclick onmouseover etc to a http request that then calls the coderef that was assigned to it and returns some javascript or html to suit (obviously you'd not map every event, only those for which there was something meaningful to call).

    ...convert the various closure and tied variable interfaces into XHR...

    I'd most definately not want to convert the callbacks and send them off as javascript - not because it's a bad plan, but more because i have a blood condition, and code like that would start a nosebleed for sure!

     HTML::Widget

    Hey Neat! there's a bundle of code i don't have to write myself

    Tk's interface is ... kinda... not... good

    I'll give wxperl an oggling too... Since Ihave next to no knowledge of my own, anything is a welcome addition! If you know of an API that you think is good, I'd love to know before I belt out some code, although i figured if i manage to pull even a fraction of this off, it would benifit more people since (based on statistics i just made up then) more people are using Tk for their GUI's than any other library

    Also, it occurred to me that you could simply drop your Tk applicatoin in $public_html_directory and add a directive to the config files for $webserver that adds the magical TkJax libraries into @INC before the place the Tk libs normally live, and Viola! instant web application (oddly, this seems like it would be a little way down the track).

    I'll see if I can smack together a bit of a Hello World type example, and see how it goes from there ...

    will: do{ perl programming } for $cash;