Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Encapsulating web client side code in Perl modules?

by mpeters (Chaplain)
on May 08, 2007 at 21:50 UTC ( [id://614258] : note . print w/replies, xml ) Need Help??

in reply to Encapsulating web client side code in Perl modules?

The concept of cooperation between client-side Javascript and server-side Perl where the Javascript is totally encapsulated/hidden within a Perl module strikes me as a promising approach:

Actually this strikes me as the wrong way to do it. Anytime you try to encapsulate one system into another you have 1 of 2 choices:

  1. Limit your usage to only a subset of the wrapped system's functionality
  2. Make your interface to the wrapped system just as complete and complicated as the wrapped system itself.

GWT (Google's Java system to have users avoid writing Javascript for AJAX apps) recently ran into problems with users because they needed to do things that were easy in Javascript but that GWT didn't provide an interface for. Now Java programmers using GWT have the option of passing in strings of Javascript that GWT then injects into the pages. Try debugging that if something goes wrong.

Plus their Java code is now littered with Javascript code. It's the same principle of littering HTML throughout your Perl programs. It was bad in the 90's and it's even worse now.

we can make the web client more productive without having to write an extensive amount of Javascript as some set of functionality can be provided via Perl modules.

Why are you so scared of Javascript? It's not the same beast it was in the 90's and can actually be quite pleasant if you're using the right framework (my favorite poison is Prototype).

Javascript is only going to get more and more important for web technologies. You are really doing yourself a disservice by trying to hide from it.

-- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier
  • Comment on Re: Encapsulating web client side code in Perl modules?

Replies are listed 'Best First'.
Re^2: Encapsulating web client side code in Perl modules?
by webshop (Acolyte) on Feb 24, 2009 at 15:03 UTC
    Javascript OO extension that work with a dollar sign means that you have to be extra careful when embedding JS/HTML inside a Perl script, otherwise perl will try to process the ${'something'} as a perl variable and the JS won't work properly. Are there any recommended solutions to this issue, like a Perl module for communicating with Prototype / Dojo / Mootools applications?