Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Perl/Tk Applet for Web

by neversaint (Deacon)
on Sep 07, 2007 at 14:22 UTC ( [id://637659]=perlquestion: print w/replies, xml ) Need Help??

neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,
Is it possible to build an applet using Perl/Tk (or other relatives of it) and use it from the web?
So I think this is not like CGI.pm (although it may work under it).

I am thinking of something like Java Applet which people can interact with graphics etc2 as an apps on the web.

Is there any existing of such script and example for Perl/Tk, we can refer to? Any pointer would be greatly appreciated.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Perl/Tk Applet for Web
by renodino (Curate) on Sep 07, 2007 at 16:07 UTC
    At the risk of going off topic, do you really need to run a Perl/Tk (or any other non-browser) GUI for your app ? You might be surprised at what is possible inside the browser these days. E.g., take a quick look at YUI and Ext (among many others). If the issue is interaction with the local desktop, AIR may solve that problem (if one ignores security issues).

    Yes, it requires learning Javascript and CSS. But thats probably a good idea/career move anyway.


    Perl Contrarian & SQL fanboy
Re: Perl/Tk Applet for Web
by zentara (Archbishop) on Sep 07, 2007 at 17:42 UTC
    You are seeking the "Holy Grail". :-) I was just asking the same thing in Re: How to answer "Perl is not secure" objections? and mr_mischief laid out the reasons it dosn't exit. It's the number1 thing on my wishlist.

    The aforementioned PerlPlus plugin was the last (5 years ago) attempt, but it was frought with security problems, because it was based on a real perl interpreter. Don't waste your time on it, except for educational purposes.

    What you can do easily, is setup custom Tk or Gtk2 scripts, which access some server and display information, but your clients will not be using a browser, but your script. I've made toy multiplayer games, which have Tk frontends, which work over the internet. Actually, these can be made more secure than what a browser's 128 bit encryption can give.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Perhaps this is a good place to mention a buzzword. If one knows some JavaScript as well as Perl, they can make a powerful team. Using JavaScript to dynamically call the server and update a web page, one can get lots of Perl (or another language) goodness combined with JavaScript's access to the client and its DOM. The buzzword here is 'AJAX'.

      Also, there are a number of tools meant to ease the production of AJAX-enabled web pages from Perl. Some seem to even lessen the need to know JavaScript well for more basic uses. AJAX gives us HTML::Prototype, HTML::Prototype::Js, OpenThought, AEAE, HTML::AjaxTags, JQuery, and more.

      This doesn't give exactly the same kind of advantages that Flash and such do. However, it can get pretty close, and there's no plugin required. When (if?) SVG is standardized across browsers, it'll be even closer. JavaScript isn't in every browser nor allowed to be active at every location, but then neither are plugins.

      A thought occurs to me that it wouldn't even be a good idea to focus efforts on securing a Perl plugin and promoting it. ActionScript is pretty powerful, and Flash is pretty widespread. There's nothing keeping other languages from compiling down to SWF, which is a more-or-less open format.

      The HaXe language does just that. HaXe can target Flash, JavaScript, or nekoVM although what's possible is a little different in each case. Some of the functionality is through libraries, so the core language doesn't get polluted with target-specific abilities that don't exist on other targets.

      Multiple backends is a goal of Perl6 IIRC -- parrot, a JIT, JVM, perhaps CLR, etc. Perhaps modules could be made that allow Perl5 and/or Perl6 with some graphics and sound lib calls to compile down to Flash. I'm not sure Tk, Gtk+, SDL, OpenGL, or whatever would be exactly suitable, but perhaps a subset of one or more of those could be squeezed in. A separate Flash library module might be necessary.

      Update (2007-09-07 21:12Z): I've found references to SWF::Builder and SWF::File. Those require a some knowledge of the Flash concepts, but they look usable enough. It shouldn't be any harder than picking up a Perl interface to some other library. teabag has a pretty interesting CUFP using SWF::file at plong - a pong clone with SWF::File.

        a pretty interesting CUFP using SWF

        The link in my sig leads to a SWF made with SWF::Builder. :-) The SWF::Builder stuff is cool, but not quite perfected yet for access from Perl, there are alot of things which should work, but don't.

        FWIW, I was watching the CNBC Business Channel a few weeks ago, and a plug was put in for Adobe, who is supposedly about to release some sort of "next generation" content generator, which according to the reporter, will blow everything else away, and become the standard...... of course, it may have just been stock pumping. :-)


        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
        One of the "and more" options for your list is CGI::Ajax, which allows you to do a lot in web pages by calling your Perl server with the values of HTML fields, then inserting the returned text into a div on the page, no JavaScript knowledge required. Of course, if you do apply some of your own JavaScript knowledge on top of CGI::Ajax's magic, you can do even more with it.

        I found it very easy to just pick up and use. The hardest and most time-consuming part of learning it, for me, was rereading the documentation a few times until I was convinced that it really was as simple as it looked.

Re: Perl/Tk Applet for Web
by jbert (Priest) on Sep 07, 2007 at 14:44 UTC
    Well, it *is* possible to run perl code in the browser, via the Windows Scripting Host. But:
    • It requires that all users install the relevant software (and run windows) - i.e. you must have a captive audience
    • I'm not sure you'll get much in the way of graphical effects, you'll effectively be using perl as a replacement for client-side javascript.
    But I may have misunderstood the technology. Given the need for installation, it's rare that this approach would make sense, anyway.
Re: Perl/Tk Applet for Web
by erroneousBollock (Curate) on Sep 07, 2007 at 14:53 UTC
    The PerlPlus plugin seems to have been an effort along those lines... no idea if this worked well or if it's still useful.

    There's also the official-ish TCL/TK plugin for browsers... you probably can't use that directly but the Tcl::Tk module source may give you some ideas.

    -David

Re: Perl/Tk Applet for Web
by moritz (Cardinal) on Sep 07, 2007 at 14:33 UTC
    I know of no such solution, and I don't think there is one.

    I heard of an effort to create an MVC framework that can use either a web server+browser or a GUI as its frontend (I forgot the name, sorry), but I think that's still experimental, and it will not work with an arbitary Perl/TK app.

Re: Perl/Tk Applet for Web
by stonecolddevin (Parson) on Sep 07, 2007 at 23:57 UTC

    Holy Grail indeed.

    If one was able to create something like this, they'd magically have something to compete with Java, Flash and other such GUI esque plugins for the internet.

    I think this is something that's a little do large to try and tackle, especially looking back at the tribulations Flash and Java (alone) have endured.

    So solly Cholly!

    meh.
Re: Perl/Tk Applet for Web
by randyk (Parson) on Sep 08, 2007 at 17:52 UTC
    The security issues mentioned above are major considerations, but, given that, you may also want to look at Par-WebStart, which is a Perl implementation of Java's Web Start.
Re: Perl/Tk Applet for Web
by Anonymous Monk on Sep 08, 2007 at 04:12 UTC
    It's called an exploit. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://637659]
Approved by Corion
Front-paged by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found