[tpm] Javascript

Brandon McCaig bamccaig at gmail.com
Mon Jun 16 15:18:22 PDT 2014


On Sat, Jun 7, 2014 at 11:43 PM, Liam R E Quin <liam at holoweb.net> wrote:
> The best way in general is to give up and use jQuery.
>
> Good JavaScript tends to use functions a lot, rather like Perl anonymous
> subroutines.

I concur with Liam. You definitely want some kind of standardized
cross-browser interface like jQuery to do JavaScript programming.
jQuery comes with lots of nice features that make working with
JavaScript less of a headache, and actually kind of fun.

One reason for using lots of functions in JavaScript is because
JavaScript only has two scopes: object (i.e., global state is
implicitly attached to a global object, usually window) and function.
If you want a nested scope you can wrap it in a function. Another
reason is closures. They can be used to control access to data and
pass behaviors around. The event-driven model requires it, and the
asynchronous nature of "AJAX" does too.

I have worked a lot with JavaScript. I haven't used it together with
Perl, but for all intents and purposes you don't anyway. JavaScript
executes on the client. Perl executes on the server. Completely
different environments with completely different purposes. JavaScript
and Perl have relatively little in common. They can do many of the
same things, but they do them very differently.

The inheritance model in JavaScript is interesting to explore, but the
object model is much less open or accessible compared to Perl's.

JavaScript is a language that you will probably hate to start, and
eventually will learn to reluctantly appreciate it for what it is. The
language itself bad. It's the non-standard and/or crappy browser APIs
that cause the major headaches.

Regards,


-- 
Brandon McCaig <bamccaig at gmail.com> <bamccaig at castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'


More information about the toronto-pm mailing list