Open Raynos opened 10 years ago
No arguments from me on with
, eval
, do ... while
, switch
, ==
and void
.
I'm all about removing semantics that clutter the language. I'd like to refrain from removing certain points of syntax, even when optional or duplicated. I'm not necessarily shutting down the idea, but I'd like to focus first on removing semantics before opening the flood gates of preferred syntax. This would be the case for:
if (err) return cb(err)
Not entirely sure what you mean by "shadowing local variable names in closures."
Rather than directly discuss "strict mode by default" we should just talk about the parts of the language that strict will remove.
I'm going to table any changes to for
loops until we have time to explore some standard functions for functional programming that actually compile down to faster for
loops under the hood. Once we see what we can do with that we could potentially remove for
all together, but I'm not going to bet on it yet.
@mikeal
Shadowing local variables
function () {
var foo = 'bar';
function baz() {
var foo = 'baz';
/* 100 lines of code */
return function () {
return foo.toUpperCase();
}
}
}
if you can shadow a variable you can redefine the same local variable at a more "local" scope. this creates ambiguity unless you read ALL the code.
functions assigned to variables (use declarations instead) expressions without block if (err) return cb(err)
These are just bikesheds, dont really care, i think it's my minimalism OCD.
remove optional semicolons, get rid of ASI.
This is not a bikeshed.
Forgetting to do ;[1, 2, 3].forEach()
is a source of bugs if you don't know how ASI works and dont use semicolons.
A language without ASI is a simpler language.
I'm going to table any changes to for loops
:+1:
I'm all for:
for (var i = 0; i < 10; i++) {
doShit();
}
and I'm all for
while (condition) {
doShit();
}
In fact, imho a fif or js-- should support all of asm.js.
However we should get rid of
for (var k in obj) {
/* oops forgot hasOwnProperty check */
var v = obj[k];
doShit(v)
}
In fact it's known that a for ... in
loop with a hasOwnProperty
check is slower then using Object.keys(o)
and a for
loop.
There is zero need to keep for ... in
for performance reasons because it's actually slower then Object.keys(...)
Let's start a separate ticket about ASI.
I have similar concerns about for (var x in obj)
I just think it could be cleaner to find a way to remove for
altogether if we can create better standard functions for loops.
@mikeal
I think getting rid of for loops means asm.js is not a subset of fif.
Let me open seperate issues.
Just removing
this
is the first step. There are so many other things we can remove.For example
with
eval
for (var x in foo)
do ... while
loopsswitch
statementsvoid
keyword==
can go away.if (err) return cb(err)