http://www.perlmonks.org?node_id=710161


in reply to Re^2: [OT] Perl / Computer Science Science Fair Projects
in thread [OT] Perl / Computer Science Science Fair Projects

I ran across that, and immediately decided that there was so little backwards compatibility that I was going to forget it again.

Also you can't use the let keyword unless you've explicitly declared that you're using version 1.7.

<script type="application/javascript;version=1.7"> ... </script>
which strikes me as a very annoying design choice.

Replies are listed 'Best First'.
Re^4: [OT] Perl / Computer Science Science Fair Projects
by BrowserUk (Patriarch) on Sep 09, 2008 at 20:35 UTC
      It is certainly similar, and was done for a similar reason.

      However the Perl version had better cause to do it (there is popular code in the wild which conflicts with Perl 5.10 features, whereas worries about functions named "let" are more theoretical), and did it with a language mechanism that is used by a lot of third party modules.

      But there are other significant differences. The JavaScript version has horrible action at a distance. If my library uses let, you have to know that when you load it in a different file. How to do it is not obvious. If I have multiple JavaScript snippets, I have to include that feature in each one. If I wish to inline some JavaScript in a tag, there is (as far as I know) absolutely no way for me to say that I want features turned on. (Yes, in autogenerated code it sometimes does make sense to put complex JavaScript in tags.) Furthermore if I'm a novice bitten by JavaScript's unusual scoping rule, there is no easy way for me to discover that workaround.

        If I wish to inline some JavaScript in a tag, there is (as far as I know) absolutely no way for me to say that I want features turned on.

        Specifying the default scripting language, from the HTML spec.

        (I'm not disagreeing with anything you said. I just thought you might be interested in this.)

        Way way off the OP topic but...

        Specifying the version in a single <script> tag doesn't seem all that big a deal to me. Load a single js file with that tag and then load all other external scripts programmatically with the XPCOM inteface @mozilla.org/moz/jssubscript-loader or something like JSAN. That way everything else loaded specifies the same version, then add your inline script attributes and/or event handlers programmatically as well.