Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
should issue a warning when "strict mode"; is missing
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 50 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas Shinnick  
View profile  
 More options Jan 21 2012, 1:27 pm
From: Thomas Shinnick <tshin...@gmail.com>
Date: Sat, 21 Jan 2012 10:27:42 -0800 (PST)
Local: Sat, Jan 21 2012 1:27 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

On Friday, January 20, 2012 11:49:40 PM UTC-6, Matt Sergeant wrote:

> Why 0b and not 0o? Surely 0b should be binary?

Argh, typo.  Yes,  0b101010  and  0o55.  They are talking about explicitly
_not_ supporting 0O55 as too typographically confusing.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon Benvie  
View profile  
 More options Jan 21 2012, 2:58 pm
From: Brandon Benvie <brandon.ben...@gmail.com>
Date: Sat, 21 Jan 2012 11:58:30 -0800 (PST)
Local: Sat, Jan 21 2012 2:58 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

Exactly what isaacs said. It doesn't provide a benefit outside of a handful
of specific scenarios. It certainly doesn't increase performance and up
until recently was harmful to performance. In return you will subtly change
the functioning of existing code in ways that can be difficult to track
down.

Certainly go ahead and use it for writing new stuff, but the idea of
blanket applying it downright stupid and dangerous because it *will* often
break code not specifically written with the differences in mind.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcel Laverdet  
View profile  
 More options Jan 21 2012, 3:44 pm
From: Marcel Laverdet <mar...@laverdet.com>
Date: Sat, 21 Jan 2012 14:44:26 -0600
Local: Sat, Jan 21 2012 3:44 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

I feel omitting semicolons is hazardous as well, and as long as you aren't
omitting them you won't run into this problem. I think optional semicolons
are fine when a language is designed for it, but in JS they lead to
ambiguities like this.

function foo() {}
var foo = foo()
foo ? bar() : etc()

The above is fine. But if you add an innocent paren the meaning of the
program changes entirely:

function foo() {}
var foo = foo()
(foo) ? bar() : etc()

Anyway I've developed strict coding standards to avoid the pitfalls of
semicolon insertion in JS, as I'm sure semicolon non-believers have had to
do as well. It's just annoying because the way JS is designed, neither
"never using semicolons" or "always using semicolons" is safe.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Miller  
View profile  
 More options Jan 20 2012, 3:20 pm
From: Mark Miller <erig...@gmail.com>
Date: Fri, 20 Jan 2012 12:20:26 -0800
Local: Fri, Jan 20 2012 3:20 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

Hi Isaac, because of this octal impediment, we've decided to support 0o666
octal literals, and 0b10101 binary literals while we're at it, to ES6.
However, in the meantime, I think this is a truly terrible reason to burden
the community with the continued presence of non-strict server-side code.
Think of non-strict code as toxic waste -- we can't deny its inevitable
continued existence, but let's please keep it out of places where people
are still living (active code being actively maintained). It isn't even
lexically scoped. Going forward, its only remaining purpose should be to
keep old websites working even when their sources are no longer being
actively maintained, i.e., most of the web, but essentially none of NodeJS
or other server-side code.

+1 to adding "use strict" to the module wrapper, so that all server side
code is implicitly strict, whether it says so or not. Having uses of octal
be a bit more awkward is a small price to pay for the increase in sanity.

--
Text by me above is hereby placed in the public domain

  Cheers,
  --MarkM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options Jan 21 2012, 4:49 pm
From: Isaac Schlueter <i...@izs.me>
Date: Sat, 21 Jan 2012 13:49:23 -0800
Local: Sat, Jan 21 2012 4:49 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing
Mark,

All the JavaScript in node-core gets linted.  (We're not warning-free
yet, we're getting closer.)  We do not have octal literals in the
node-core JavaScript.  If you find any JavaScript in node that is not
strict-compliant already, please send a patch.  That is a bug, and
would be highly surprising.

Past analysis (in node 0.5) showed that adding "use strict" made our
benchmarks relevantly worse.  If that changes, we'll start adding "use
strict" in node's internal JavaScript.  As long as the "toxic waste"
is faster, we'll keep using it.  Winning is more important than being
right.

On Sat, Jan 21, 2012 at 12:44, Marcel Laverdet <mar...@laverdet.com> wrote:
> The above is fine. But if you add an innocent paren the meaning of the
> program changes entirely:

> function foo() {}
> var foo = foo()
> (foo) ? bar() : etc()

> Anyway I've developed strict coding standards to avoid the pitfalls of
> semicolon insertion in JS, as I'm sure semicolon non-believers have had to
> do as well. It's just annoying because the way JS is designed, neither
> "never using semicolons" or "always using semicolons" is safe.

Marcel, you know full well that responsible semicolon minimalists
would balk at the very notion of starting a line with ( and not
prefixing it with a semicolon.

This "always" "never" business is a strawman duel.  No one who knows
what they're talking about endorses either.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Schmidt  
View profile  
 More options Jan 21 2012, 7:09 pm
From: Ryan Schmidt <google-2...@ryandesign.com>
Date: Sat, 21 Jan 2012 18:09:38 -0600
Local: Sat, Jan 21 2012 7:09 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

On Jan 21, 2012, at 14:44, Marcel Laverdet wrote:

> Anyway I've developed strict coding standards to avoid the pitfalls of semicolon insertion in JS, as I'm sure semicolon non-believers have had to do as well. It's just annoying because the way JS is designed, neither "never using semicolons" or "always using semicolons" is safe.

I always use semicolons where they belong, or at least, that is my intention. In what way is this not safe?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jann Horn  
View profile  
 More options Jan 21 2012, 8:27 pm
From: Jann Horn <jannh...@googlemail.com>
Date: Sun, 22 Jan 2012 02:27:10 +0100
Local: Sat, Jan 21 2012 8:27 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing
2012/1/20 Mark Miller <erig...@gmail.com>:

> +1 to adding "use strict" to the module wrapper, so that all server side
> code is implicitly strict, whether it says so or not. Having uses of octal
> be a bit more awkward is a small price to pay for the increase in sanity.

Would this also force REPL users to write strict JS?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Seva Adari  
View profile  
 More options Jan 22 2012, 1:27 am
From: Seva Adari <oddiss...@gmail.com>
Date: Sat, 21 Jan 2012 22:27:18 -0800 (PST)
Local: Sun, Jan 22 2012 1:27 am
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

>  It certainly doesn't increase performance and up until recently was
> harmful to performance.

This is a bit counter intuitive, but I suppose the checks that it forces
adds a cost to performance. One way to deal with it is to turn it on during
the development and may be remove it during the deployment (or in
production). If there is a single configuration option with which this can
be achieved then it is all the better.

> Certainly go ahead and use it for writing new stuff, but the idea of
> blanket applying it downright stupid and dangerous because it *will* often
> break code not specifically written with the differences in mind.

I can't imagine code breaking often for using 'use strict' in all use
cases. Even if you can avoid it for now, isn't the JS language itself is
going in that ( 'use strict') direction. Future versions will be far more
less forgiving than the current.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcel Laverdet  
View profile  
 More options Jan 22 2012, 3:46 am
From: Marcel Laverdet <mar...@laverdet.com>
Date: Sun, 22 Jan 2012 02:46:21 -0600
Local: Sun, Jan 22 2012 3:46 am
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

@mark

> +1 to adding "use strict" to the module wrapper, so that all server side

code is implicitly strict, whether it says so or not. Having uses of octal
be a bit more awkward is a small price to pay for the increase in sanity.

Bit surprised to hear this from you! It seems dangerous to introduce this..
Without "use strict" it's impossible to tell the toxic waste from
otherwise, among other hazards.

@isaac

> Marcel, you know full well that responsible semicolon minimalists would

balk at the very notion of starting a line with ( and not prefixing it with
a semicolon.

> This "always" "never" business is a strawman duel.  No one who knows what

they're talking about endorses either.

Dude I wasn't trying to turn this into a duel. I'm saying that neither
solution is ideal because of the way the language is designed. Instead of 1
great way to do things we have 2 mediocre ways to do things. Semicolonites
and minimalists alike have to adhere to extra-grammatical rules in order to
write properly functioning applications.

@ryan

> I always use semicolons where they belong, or at least, that is my

intention. In what way is this not safe?

For the most part you should be fine. The only thing I could realistically
imagine biting you is the example above.
function foo() {
  return
    'foo';

}

foo() returns undefined!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Jouhier  
View profile  
 More options Jan 22 2012, 8:28 am
From: Bruno Jouhier <bjouh...@gmail.com>
Date: Sun, 22 Jan 2012 05:28:03 -0800 (PST)
Local: Sun, Jan 22 2012 8:28 am
Subject: Re: should issue a warning when "strict mode"; is missing
What about a "stricter" option to get a warning or error whenever the
compiler automatically inserts a semi-colon. Looks like this would
make things safe for "semicolonites".

With:

  return
    foo;

you would get a warning about a semicolon being added at the end of
the return line.

But with:

  return foo;

you would not get any warning.

Should not be too difficult to hack into a preprocessor.

Bruno

On Jan 22, 9:46 am, Marcel Laverdet <mar...@laverdet.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Miller  
View profile  
 More options Jan 22 2012, 10:14 am
From: Mark Miller <erig...@gmail.com>
Date: Sun, 22 Jan 2012 10:14:38 -0500
Local: Sun, Jan 22 2012 10:14 am
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

On Sun, Jan 22, 2012 at 1:27 AM, Seva Adari <oddiss...@gmail.com> wrote:
>  It certainly doesn't increase performance and up until recently was
>> harmful to performance.

> This is a bit counter intuitive, but I suppose the checks that it forces
> adds a cost to performance.

That's not it at all. When designing strict mode, we were very careful to
ensure that any effect it had on performance would be positive. For an
optimizing engine like v8, strict vs non-strict won't have much of a speed
advantage, as most potential gains have already been achieved by harder
analysis. But with the comparable engineering effort, there should
certainly be no penalty for using strict.

Rather, the issue is "comparable enginerring effort". I just verified with
one of the v8 people that problem is that none of the benchmarks say "use
strict";. To get this situation repaired, I suggest that someone in the
Node community should release, for example, "NodeSpider", a variant of
SunSpider in which all the tests are run in strict mode. In addition, if
you capture the particular cases that are causing node code to slow down
and turn these into further NodeSpider tests, that would be great. If
NodeSpider gets any prominence at all, any remaining penalty for strict
mode would disappear quickly, and strict mode may even start to realize
some advantages. The v8 team likes to drive their optimizations efforts by
things they can measure.

> One way to deal with it is to turn it on during the development and may be
> remove it during the deployment (or in production). If there is a single
> configuration option with which this can be achieved then it is all the
> better.

That would be an improvement on the status quo. But it reminds me of a
comment by Tony Hoare about array bounds checking. Many people at the time
wanted to have array bounds checking turned on during development to help
catch bugs, but then turn it off in deployment for extra speed. Hoare
described this as[1] "Like turning off all the safety devices on an
airplane just before it is about to start carrying passengers".

[1] Paraphrasing, since I can't find it. If anyone knows the exact post or
where to find it, please let me know. Thanks.

>> Certainly go ahead and use it for writing new stuff, but the idea of
>> blanket applying it downright stupid and dangerous because it *will* often
>> break code not specifically written with the differences in mind.

Because the browser has to remain compatible with a universe of legacy no
one can change, we have no choice there. For node, any code that doesn't
work in strict should already be considered broken. Going forward, no one
new to JavaScript should ever be taught the non-strict language. And even
today, very few who think they understand JavaScript really even understand
the non-strict language. The illusion of understanding is mostly due to
ignorance of the odd corners.

> I can't imagine code breaking often for using 'use strict' in all use
> cases. Even if you can avoid it for now, isn't the JS language itself is
> going in that ( 'use strict') direction. Future versions will be far more
> less forgiving than the current.

It is indeed. But for the sake of maintaining backward compatibility with
ES5-strict, future versions will likely be no more nor less forgiving that
current strict mode is.

--
    Cheers,
    --MarkM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Miller  
View profile  
 More options Jan 22 2012, 10:48 am
From: Mark Miller <erig...@gmail.com>
Date: Sun, 22 Jan 2012 10:48:08 -0500
Local: Sun, Jan 22 2012 10:48 am
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

On Sun, Jan 22, 2012 at 3:46 AM, Marcel Laverdet <mar...@laverdet.com>wrote:

> @mark
> > +1 to adding "use strict" to the module wrapper, so that all server
> side code is implicitly strict, whether it says so or not. Having uses of
> octal be a bit more awkward is a small price to pay for the increase in
> sanity.

> Bit surprised to hear this from you! It seems dangerous to introduce
> this.. Without "use strict" it's impossible to tell the toxic waste from
> otherwise, among other hazards.

I suppose another possibility would be to reject all code that doesn't
begin with "use strict";, but I expect this wouldn't go over well.

Node is a new platform. It isn't a browser. It can define what variant of
JS it accepts. I see little reason for node to continue to support
ES5-non-strict and much reason not to.

--

  Cheers,
  --MarkM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikeal Rogers  
View profile  
 More options Jan 22 2012, 1:31 pm
From: Mikeal Rogers <mikeal.rog...@gmail.com>
Date: Sun, 22 Jan 2012 10:31:36 -0800
Local: Sun, Jan 22 2012 1:31 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

Let me just shut down this thread, hopefully.

node.js does not have an opinion about the JavaScript language.

never has. never will.

That includes strict mode, and ES.next features in case anyone was wondering.

node.js takes v8 "vanilla", no changes, no tweaks. If v8 doesn't warn w/o strict mode, neither does node.js.

This is less a technology decision and more of a community/focus decision. We succeed by limiting the surface area of the problem we are trying to solve and the language isn't part of that.

If you want node.js to warn on strict, tell the v8 people :)

-Mikeal

On Jan 22, 2012, at January 22, 20127:48 AM, Mark Miller wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dick Hardt  
View profile  
 More options Jan 22 2012, 1:38 pm
From: Dick Hardt <dick.ha...@gmail.com>
Date: Sun, 22 Jan 2012 11:38:21 -0700
Local: Sun, Jan 22 2012 1:38 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

+1

On Jan 22, 2012, at 11:31 AM, Mikeal Rogers wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options Jan 22 2012, 4:31 pm
From: Isaac Schlueter <i...@izs.me>
Date: Sun, 22 Jan 2012 13:31:04 -0800
Local: Sun, Jan 22 2012 4:31 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing
Mikeal, did you ever know that you're my hero?

On Sun, Jan 22, 2012 at 10:38, Dick Hardt <dick.ha...@gmail.com> wrote:
> If you want node.js to warn on strict, tell the v8 people :)

I wouldn't be opposed to an env/cmdline/compile-time flag to make Node
add "use strict" to all modules it loads.  But it'd have to be clean,
and introduce no other hazards, or break anything that already works.
And if it's not demonstrably faster, it won't be the default.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Schmidt  
View profile  
 More options Jan 22 2012, 4:38 pm
From: Ryan Schmidt <google-2...@ryandesign.com>
Date: Sun, 22 Jan 2012 15:38:59 -0600
Local: Sun, Jan 22 2012 4:38 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

On Jan 22, 2012, at 02:46, Marcel Laverdet wrote:

>> I always use semicolons where they belong, or at least, that is my intention. In what way is this not safe?

> For the most part you should be fine. The only thing I could realistically imagine biting you is the example above.
> function foo() {
>   return
>     'foo';
> }

> foo() returns undefined!

Of course it does. I wouldn't expect it to do anything different. :)

It would also never occur to me to write the above code. If I wanted to return 'foo' I would write:

return 'foo';

If I wanted to return undefined I would write:

return;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AJ ONeal  
View profile  
 More options Jan 22 2012, 10:57 pm
From: AJ ONeal <coola...@gmail.com>
Date: Sun, 22 Jan 2012 20:57:48 -0700
Local: Sun, Jan 22 2012 10:57 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

*The Lose-Lose Case*
===

I'm not saying that, if there is absolutely no possible way to work around
the flaws inherent in the system, that you should not get the work done.

Rather, what I'm saying is that you should adhere to the rules first and
cater to the exceptions on a case by case basis.

I realize that test-driven development kind of trains your brain to
consider every possible edge-case (and a lot of people have that
pre-optimization mentality anyway), but...

*This is a 90 / 10 problem.*
===

What percentage of NodeJS developers use Octal?
What percentage of JavaScript *users* use Octal?

What percentage of JavaScript *users* don't realize that if they forget
`var` their variable becomes a global?

The question here isn't about the 1% that use these features, it's about
80% that get tripped up by simple newbie mistakes.

*With more power comes more responsibility*
===

I would rather cause disciplined devs like you and me a little grief here
and there than every single newbie that comes into JavaScript and NodeJS
suffer completely unintuitive silent errors and such.

If Octal is so important for the NodeJS devs, then add a core module for
the basic operations. But what about the users?

*It's about the user*
===

Do you see what I'm saying? *Application languages* - JavaScript, ruby,
python, etc - *are about abstraction. That is their purpose!*

Not wanting workarounds isn't "lazy". I'm pretty sure that if you have

> to replace well-written stuff that just works with "workarounds", this
> is a huge -1 on that change.

If it were well-written, it shouldn't have any issues in strict mode other
than the octal change.

> > (function () {
> >   "use strict";

> Without the indent. Please.

I'm okay with that. It just looks weird without the indent to me.
If I had seen some sort of precedent without the indent, I would have used
it that way.

> Globals are EVIL. BAD. RUDE. INCONSIDERATE. NASTY.

> > I can't believe I'm hearing support for globals!!

> I think you're exaggerating a lot here. What about, for example,
> "process"? Or what about logging?

I wish so bad that it were required instead.

It has caused me extra work (albeit minimal) to get some node / npm modules
to run in the browser because `process` is used.

> > I'm being sincere. I thought that everyone in the programming communities
> > had gotten the memo that globals and gotos are words you feel dirty
> inside
> > for using (except in the kernel where you use gotos to implement the
> > decorator pattern without the overhead of function calls - and the people
> > there are hopefully disciplined enough to not make severe design
> mistakes).

> Uh? So you're basically saying "globals aren't too bad, but they're
> sharp tools that can be used for nasty stuff, so drop them and use
> this wooden knife instead"? Yes, it sometimes is bad to use them, and
> yes, it's not what we should put on top of tutorials, but we
> definitely shouldn't discourage them that much.

I was saying that `goto` takes the place of the decorator pattern in C,
since C is a hardware language with a limited feature set, not an
application language with wonderful abstractions.

The kernel isn't an application. It has a different set of design patterns
than applications do.

Applications should not use globals.

> > Browser
> > ---
> > You don't need globals either. A TON of effort has gone in to making sure
> > that you can write modular JavaScript. Thanks to RequireJS, Pakmanager,
> and
> > Ender, you can install straight from npm into packed browser-safe code.

> What about JSONP? You need global functions for that, no?

Actually, for all modern browsers (including MSIE), JSONP is no longer
necessary.
Welcome CORS and XHR2. :-D

I'm not saying that, if there is absolutely no possible way to work around
the flaws inherent in the system, that you should not get the work done,
but that you should adhere to the rule first and cater to the exceptions on
a case by case basis.

(And actually, I've been considering writing a `window` module for the
browser that copies the properties that are actually part of `window`)

> > Octals
> > ---
> > I guess since a lot of people on this list work with c++ for native node
> > modules it makes sense.

> Uh... and e.g. working with the filesystem, too.

> > But JavaScript is a high-level language primarily used for interacting
> with
> > users.
> > If you want to use octals... USE C!

> Ah, right, Javascript doesn't belong on the server or so. You're sooo
> right.</scnr>

JavaScript is an application laguage. It works just as well on the server
as ruby or python - just a bit better because it handles JSON natively and
has a built-in event system.

> > Do you know how many times I've been bitten by parsing user input that
> had a
> > leading '0' and have scratched my head for too long trying to figure out
> > where the math had gone wrong? A lot! (but I'm getting better and
> > remembering to check for corner cases that strict mode can't protect me
> > from);

> Well then, sounds like you're using the wrong tools to parse user
> input. And like you're not reading documentation. E.g. parseInt only
> tries to determine the radix based on the input if you don't
> explicitely specify it.

That's exactly my point. I *want* an application language to hold my hand a
little (or at least be intuitive - there should be a parseOct and parseHex
- or do you have an argument or using a radix of 3 and 7 as well?).

If I wanted to have absolute full control I'd use C.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AJ ONeal  
View profile  
 More options Jan 22 2012, 11:08 pm
From: AJ ONeal <coola...@gmail.com>
Date: Sun, 22 Jan 2012 21:08:30 -0700
Local: Sun, Jan 22 2012 11:08 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

> In return you will subtly change the functioning of existing code in ways
> that can be difficult to track down.

I don't believe so. All of the changes to strict mode throw errors.

this = null -- throws an error
using octal -- throws an error
not declaring a variable -- throws an error
using with -- throws an error

in which case would the problem be subtle?

Exactly what isaacs said. It doesn't provide a benefit outside of a handful

> of specific scenarios. It certainly doesn't increase performance and up
> until recently was harmful to performance.

Those handful of scenarios are the things that newbies trip up on most (I
remember being a newbie, do you?)

I'm part of the training process new hires, some of which are new to JS.
There's a reason that strict mode exists. It IS to help.

Youth and Beauty
===

I'm not saying to enable strict mode by default,
I'm saying to add a warning when it isn't used in the app which is being
run.
(perhaps not when included with `require`, that would be annoying).

I don't believe that The changes to strict mode throw errors

Node is so young. So many newbies are getting interested in JavaScript
because of Node.

Let Node be a force of positive change.

Speed
===

Just as with binary arrays, strict mode won't gain the speed improvements
until the implementation is complete (there are still a few things lacking
in v8 last time I explicitly tested).

But as sure as Google wants v8 to be the fastest engine, the optimizations
will come, just as they have with binary arrays.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikeal Rogers  
View profile  
 More options Jan 22 2012, 11:14 pm
From: Mikeal Rogers <mikeal.rog...@gmail.com>
Date: Sun, 22 Jan 2012 20:14:58 -0800
Local: Sun, Jan 22 2012 11:14 pm
Subject: Re: [nodejs] should issue a warning when "strict mode"; is missing

On Jan 22, 2012, at January 22, 20121:31 PM, Isaac Schlueter wrote:

> Mikeal, did you ever know that you're my hero?

:)

http://www.youtube.com/watch?v=NJdMDvjfyQ0

> On Sun, Jan 22, 2012 at 10:38, Dick Hardt <dick.ha...@gmail.com> wrote:
>> If you want node.js to warn on strict, tell the v8 people :)

> I wouldn't be opposed to an env/cmdline/compile-time flag to make Node
> add "use strict" to all modules it loads.  But it'd have to be clean,
> and introduce no other hazards, or break anything that already works.
> And if it's not demonstrably faster, it won't be the default.

node's lib/* files are pre-compiled so if we want this to pertain to lib/* files it'll have to be a compile time flag.

i'm opposed to compile flags that change the behavior of node, especially in ways that you can't determine by just checking the version.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Miller  
View profile  
 More options Jan 22 2012, 11:25 pm
From: Mark Miller <erig...@gmail.com>
Date: Sun, 22 Jan 2012 23:25:54 -0500
Local: Sun, Jan 22 2012 11:25 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

On Sun, Jan 22, 2012 at 11:08 PM, AJ ONeal <coola...@gmail.com> wrote:
> In return you will subtly change the functioning of existing code in ways
>> that can be difficult to track down.

> I don't believe so. All of the changes to strict mode throw errors.

> this = null -- throws an error
> using octal -- throws an error
> not declaring a variable -- throws an error
> using with -- throws an error

> in which case would the problem be subtle?

The following actually happened to a friend of mine. A brilliant Smalltalk
programmer who has done many impressive things, but had not yet immersed
himself in JavaScript arcana for years. In order to use various primitives
in a more object-like way, he added (among other things) the following
method:

    Boolean.prototype.not = function() { return !this; };

After this, true.not() returns false as expected. Guess what false.not()
returns. Making this be instead

    Boolean.prototype.not = function() { "use strict"; return !this; };

or if this code occurs in a strict context, solves the problem. No nasty
hidden coercion surprise.

How about

    function foo(str) {
      var x = 8;
      eval(str);
      return function bar() { return x; };
    }

When bar is later called, what x variable does it read?

For both of these, the difference is not an easy to diagnose error. It is
silent confusion.

--
  Cheers,
  --MarkM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AJ ONeal  
View profile  
 More options Jan 23 2012, 12:09 am
From: AJ ONeal <coola...@gmail.com>
Date: Sun, 22 Jan 2012 22:09:58 -0700
Local: Mon, Jan 23 2012 12:09 am
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

Interesting. That's just weird.

> How about

>     function foo(str) {
>       var x = 8;
>       eval(str);
>       return function bar() { return x; };
>     }

> When bar is later called, what x variable does it read?

> For both of these, the difference is not an easy to diagnose error. It is
> silent confusion.

Okay, interesting point made.
I suppose which is expected would depend on what you would expect.

Intuitively I would expect that `str` executes in it's own context and that
`x` would always return 8.
So in not-strict mode perhaps it's possible to access `x` in `str`?

AJ ONeal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark S. Miller  
View profile  
 More options Jan 23 2012, 8:12 am
From: "Mark S. Miller" <erig...@google.com>
Date: Mon, 23 Jan 2012 08:12:18 -0500
Local: Mon, Jan 23 2012 8:12 am
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

Which behavior do you find weird:

    false.not() ==> false
or
    false.not() ==> true
?

If (as I hope) you find the first weird and surprising and would have
expected the second, it supports my case that even most experienced JS
programmers do not really understand non-strict mode. It is filled with
subtle minefields which most programs survive mostly by accident.

Actually, in both strict and non-strict mode, str can access the 'x'
variable shown here, since the eval "call" shown here is a "direct eval",
which is really a special form rather than a function call. However, in
trying to clarify, I realize that my example was flawed. The following code
correctly raises the riddle I was trying to raise above:

  function makeFoo() {
    var x = 8;
    function foo(str) {
      eval(str);
      return function bar() { return x; };
    }
  }

Again, in both strict and non-strict mode, str can access (both read and
write) the 'x' variable shown here, since the eval "call" shown here is a
"direct eval", which is really a special form rather than a function call.
So the question is not "What value does bar() return?", which could be any
value that str decides to store into the above "x" variable. The riddle is
"What x variable does bar() read?".

Once you know the answer, if you find that answer surprising, this further
supports my case. Although the strict language is still tricky, the
non-strict language is hopeless. Almost no one who programs in it actually
understands it.

--
    Cheers,
    --MarkM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon Benvie  
View profile  
 More options Jan 23 2012, 5:00 pm
From: Brandon Benvie <brandon.ben...@gmail.com>
Date: Mon, 23 Jan 2012 14:00:21 -0800 (PST)
Local: Mon, Jan 23 2012 5:00 pm
Subject: Re: should issue a warning when "strict mode"; is missing

In getting Narcissus to work in Node I had to change chunks of it to use
strict because V8's --harmony won't let you use `let` outside of strict
mode. When I did this it caused errors that I traced back to Narcissus's
use of const in eval. Instead of defining the consts in the local function
scope, they were defined globally. After finally tracking down the cause I
had to wrap the code such that the eval was done in a non-strict wrapper
function.

https://github.com/Benvie/narcissus/blob/master/lib/jsresolve.js


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Crabtree  
View profile  
 More options Jan 23 2012, 6:13 pm
From: Adam Crabtree <atcrabt...@gmail.com>
Date: Mon, 23 Jan 2012 15:13:26 -0800
Local: Mon, Jan 23 2012 6:13 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

This is mostly tangential, but usually indirect global references are used
when wanting to interact with host objects or natives, maybe not
necessarily to create globals. For some reason I can't think of any off the
top of my head, so obviously it's not THAT common, but I recall having seen
it multiple times in respected modules. Again, off the top of my head I
THINK it's usually used in the case of pollyfills, which are language
specific, environment agnostic and global in nature where the
implementation does not care about the name of the global object (window?)
so much as merely obtaining a reference to it.

Again though, if you've never encountered this issue, it's probably of
little concern to you. =)

Cheers,
Adam Crabtree

--
Better a little with righteousness
       than much gain with injustice.
Proverbs 16:8


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Crabtree  
View profile  
 More options Jan 26 2012, 2:08 pm
From: Adam Crabtree <atcrabt...@gmail.com>
Date: Thu, 26 Jan 2012 11:08:23 -0800
Local: Thurs, Jan 26 2012 2:08 pm
Subject: Re: [nodejs] Re: should issue a warning when "strict mode"; is missing

FWIW, arguments.callee is used often when passing around arguments objects.

Ben Combee pointed me to the following Mozilla ES discussion on
arguments.callee:

http://old.nabble.com/arguments.callee-and-strict-mode-td22437262.html

In short, it's deprecated to remove incidental granting of permission to
execute a function by passing its arguments object. This requires that API
consumers must now explicitly name and pass the function instead.

While I understand the security implications and reasoning for this, it
makes for a far uglier API for consumers. So in lieu of a more compelling
incentive than protection from yourself (globals) and the merit badge of
using strict mode, I don't see this as either FUD or laziness, but merely a
complication with a currently insufficient value proposition that will
necessarily and unavoidably break various APIs.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »