Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Converting Tk based Perl to be used on the Internet (meditation)

by LanX (Saint)
on May 18, 2014 at 19:02 UTC ( [id://1086536]=note: print w/replies, xml ) Need Help??


in reply to Re: Converting Tk based Perl to be used on the Interent
in thread Converting Tk based Perl to be used on the Interent

It's been over a decade that I really worked with Tk, but here some meditation on the subject.

I'll address it to you since I know that you are quite an expert on this subject.

so IMHO

  1. Tk heavily relies on callbacks.

  2. The aim of those callbacks is located somewhere between 2 extremes4

    • a) manipulating the GUI (e.g reordering elements)
    • b) interacting with the application. (e.g. access DB)

  3. Since Perl doesn't run within browsers, there are 2 options for those callbacks
    • A) porting to JS
    • B) tunneling callbacks via http to the server¹

  4. For different reasons one would mainly like to go
    • a -> A # performance
    • b -> B # complexity, server bound

  5. While it certainly is possible to mimic most (or all) Tk-widgets in HTML&JS, it's pretty unlikely to have an AI which analyzes the code to split it into a) and b) parts.

  6. The most likely solution is to design a meta-language (maybe even a DSL) which is already addressing these needs.

  7. This meta approach would create the necessary output in either Perl/Tk or Perl+JS/HTML²

  8. having a restricted sub-dialect (intersection) which reliably translates Perl <-> JS shouldn't be impossible.³

What ya think, did I miss something?

footnotes

¹) with different possible approaches for client-server communication:

  • classic http
  • AJAX
  • Web-Sockets (bidirectional)

²) or even other targets like Perl/Tkx or Perl/Wx or even Lisp/Emacs or whatever

³) But this restricted "Perl" could look very strange, e.g. only allowing scalars and hence only array-refs and hash-refs like

$array->push($a,$b)   <->   array.push(a,b)

... or only allowing function scopes and no block scopes (JS does hoisting of lexicals)

Cheers Rolf

( addicted to the Perl Programming Language)

updates

moved side-notes to footnotes.

more footnotes

4) somehow analogous to the MVC paradigm, making a distinction between template code (View) and pure Perl code (Controller).

  • Comment on Re^2: Converting Tk based Perl to be used on the Internet (meditation)
  • Download Code

Replies are listed 'Best First'.
Re^3: Converting Tk based Perl to be used on the Internet (meditation)
by zentara (Archbishop) on May 19, 2014 at 13:49 UTC
    You're hired! When can you start? :-)

    Seriously, I think that Tk is out of the running for browser based displays, for all the reasons you mentioned.

    I think that gtk3 may be the way. Why? Because firefox and many other open source browsers are currently gtk2/gtk3 based. That means that under the hood, they both would utilize the same signals and callback system.

    It looks like Python is moving forward with pyXPCOM and similar interfaces, and IIRC there is a configure option in the newer mozilla browsers to enable experimental Python support.

    It seems to me that Perl needs to get involved with XPCOM. It currently has C, C++, Python and Ruby. Where's Perl?

    Of course, I find the whole desire to run everything in a web browser rather disgusting, resulting in code bloat and html/javascript which is as hard to read as assembly language.

    In my little world, I would rather write custom scripts for clients to connect, vis ssh, keeping the browser and http servers out of it all together. :-)


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re^3: Converting Tk based Perl to be used on the Internet (meditation)
by Anonymous Monk on May 19, 2014 at 20:43 UTC
    Thank you for that.
    I am struggling a bit since although I have been using Perl for over ten years and general programming for decades before that I simply have not anywhere near the Internet programming world.
    I think you have said that Java can mimic the most Tk widgets so would be one thing to look at.
    With Java would you be able to mimic the behaviour of altering say the contents of a pull down menu because a specific radio has been used.
    What do you mean by 'meta language' and a 'DSL'?
        Thanks. I realise it is moving away from Perl but since I was starting with Perl I was hoping to find a way forward from someone who has had the same problem part as they might have understood why I was struggling.

        I am sorry you have found my foramtting troublesome. Hopefully this one will be better.

Log In?
Username:
Password:

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

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

    No recent polls found