Yeah, I think so. Moreover, as I mentioned, many programmers will
understand "strict mode" features incorrectly (I've heard even phrases
such as "we are not "children", but professionals, so use strict mode
only" -- not regarding ES, but in general -- HTML doctype, Perl, etc.).
Most PERL programs would burn up under the strict microscope. CPAN is
the Dynamic Drive of the PERL world. As for doctypes, strict makes
sense unless you are actually transitioning from one type of markup to
another.
What is laughable is that for years the majority of new sites have
used the transitional XHTML doctype.
Why? Because the developers were sure they were supposed to be using
the "more advanced" (but dead) language, but didn't really understand
why. They likely aspired to validate their creations at some point,
but found strict validation too difficult, so settled for a
"transitional" period (that has lasted a decade for some). And, of
course, faced with the fact that IE did not support XHTML for the
first decade of the century, served it with an HTML MIME type, causing
browsers to error correct it back to HTML.
Or maybe the majority are simply propagating examples from the turn of
the century via their clipboards.
Thus, presence of this feature is not related with the professionalism
in any respect.
Certainly not. In fact, putting "use strict" at the top of s script
today implies the opposite. Same for using an HTML5 doctype. Rookies
always strive to use the "coolest" new technologies, even before their
end-users are ready for them.
Using strict mode because it makes code more
professional -- is for laymen debates.
Use JSLint, but know enough to interpret the results. End of story.
Great for catching typos too.
And separating a language on
"strict" and "non-strict" will force those laymen make useless holywars.
When it comes to JS, the average developer is so completely lost that
they won't likely look for ways to make browser scripting "harder".
Hell, most of the "major" libraries can't even get through JSLint, let
alone achieve respectable results.
Also, if to look on strict mode from the other side, it's about
inattentive, but not professional programmer -- a helper which warnings
such inattentive programmer if he uses e.g. `arguments' as a formal
parameter's name.
LOL. JSLint (or the like) would flag such nonsense. Of course, if a
developer is really that out of it, they've got bigger problems.
However, for "graceful degradation" -- for example, if the language
wants to remove some obsolete garbage, it's a good feature -- to mark
those deprecated stuff in strict mode (e.g. `with' statement, which
possible will be removed from newer versions; although, for me there
have never been problems with `with', but I used it rarely).
JSLint will almost certainly flag that too. Personally, in almost
fifteen years, I've never used a - with - clause.
So from this position, `strict mode' is good. And possible someone (and
I think now someone, but about 90% of future ES programmers) will use
strict mode on the program level.
Not sure how you arrived at that figure, but I definitely disagree.
More like 10%.
And since the strictness inherits it
from the parent context, simple FD, FE will also be always strict. And
therefore, `function () {return this;}' will return `undefined'.
So don't use it (in any context). ES5 is not yet widely implemented
anyway.
And a `Function' function may help to solve this issue -- since such
functions do not inherit strictness (it's needed to write "use strict"
directly in the body of the `Function' function).
A function created by calling the Function constructor? That's
usually avoided as bad form. In terms of style, it's no better than
eval.
Yeah, agreed, that most of the discussed stuff is less about practical
cases.
Yes, and some of it is downright dangerous.
On practice, simple `var global = this;' or with `defineProperty'
is enough.
Yes.
Talks about shadowing etc. -- just theoretical things, which
can be interesting, but on practice we hardly will do this (I'm not
stupid to shadow `global' variable which I specially defined to get
global object with the local one `var global = 10' Who will do this?
Don't know.).
Right. But there will always be those who waste time seeking the Holy
Grail solution to every problem, when in context a dixie cup would
suffice.
Academical theoretic discussions are also may be interesting (I am e.g.
ECMAScript theorist, besides my practical work, which currently isn't
even massively related with JS (but was many years of course) -- I
program on Erlang now and small part on JS). Knowing this stuff allows
to quickly answer practical questions/issues which many only-practical
programmers like to name "WTF(JS)?".
That's a familiar refrain (or at least demeanor). The sad truth is
that most people involved with or on the periphery of JS see it as a
vexing mystery. I suppose that programmers that are proficient with
"real" languages like Java, C++ or whatever, feel learning a "toy"
language like JS will be an easy career boost. Once they falter in
the most marketable application of JS (browser scripting), they start
to curse it as "broken" and look for libraries to bridge the gap (as
would be natural in other languages).
What they don't realize is that the authors of most libraries are
almost as confused as they are. They see how much trouble the library
authors are having, year-in and year-out and it makes them feel
better. At this point, the whole culture is based on programming for
failure and the language is an easy (but perfectly innocent)
scapegoat.
Some of them end up here and when told that they are confused, they
are very quick to rush back to the soothing tones of blogs and Web
forums populated by people suffering from the same mass hysteria.
Others actually learn and go straight to the top of the food chain.