There's bundles of talk about AJAX this, and MVC that, and having just picked up my Perl/Tk book, I figured it'd be worth seeing if anyone has had a similarly silly idea. so, I thought to myself, how nifty it'd be if someone implemented the Tk interface in an HTML/Javascript/super-web2.0-MVC-uberframework (add or remove buzz words as you see fit)

After a bit of pondering, and some rather unhelpful search results, found a post on the Catalyst mailing list archive, that made mention of Deparse backends for javascript generation (heck, so inspired was i that i subscribed to the list)

So, having been on the list for no more than 40 minutes, and onlyl done a quick search of CPAN, I thought I'd throw the idea out there for the Taunting/Praise it demands.

Thoughts?

will: do{ perl programing } for $cash;

Replies are listed 'Best First'.
Re: Tk-esque ajax libraries
by renodino (Curate) on Oct 31, 2006 at 15:52 UTC
    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 ?

      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;
Re: Tk-esque ajax libraries
by zentara (Cardinal) on Oct 31, 2006 at 11:55 UTC
    I'm not that familiar with Ajax, but what is the goal of this question? Trying to put Tk-like graphics into web pages?

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

      Aah, a fair question... I suppose I would be aiming to see how sensible an idea it is, and if anybody has considered, is considering, has already started a project that is trying to build a workalike of the Tk API's to generate HTML and the associated Javascripts, and code to the requests generated by javascript requests back to callbacks in perl CGI (Mason,Catalyst) type scripts.

      AJAX is a buzz word for using the XMLHTTPRequest object in javascript to request nuggets of HTML from a webserver, and replacing parts of the page the user is viewing, without refreshing the page.

      Yes, I would like to represent HTML GUI's in the same language, in my code as I'd put together a GUI for a `real' running-in-a-window-manager application

      Mozilla Dev center have some fine AJAX related materials and wikipedia will tell you want an MVC is. Dojo provide some AJAX libraries, and examples. There is one for submiting golfing attempts to codegolf.com (need to signup to see) and gmail is mad for it.

      I think it could be build on Template::Toolkit and CGI::FormBuilder for displaying the things to click, but it'd be more tricky to associate a http request (perhaps with REST) back to the coderef that's associated to the clicking of the button...

      The more I write here, the more I feel like one of those newbie guys that comes on asking about something near impossible, that is far far outside his own skill set. - sadly, I am very young in Perl.

      will: do{ perl programing } for ($cash);