4 ms·
Yes. This. The ideas in the article are terrible. It does not look remotely interesting. I read these slides and think, this is someone that doesn't like JavaS
by seasoup 12y ago
Yes. This.
The ideas in the article are terrible. It does not look remotely interesting. I read these slides and think, this is someone that doesn't like JavaScript and is trying to make it more like languages they enjoy, like Java. Trying to eek out every performance improvement possible by removing developer friendly features is not a good idea.
"let" scoping is a terrible idea, it is not at all sane. Functional scoping is clean and simple, there is only one thing that scopes variables, functions. Thats it. Easy. Block level scoping will introduce coding nightmares trying to figure out what scope your variable is in. I can just imagine the nightmare code people are going to write interspersed with both var and let, and having to figure out how the variable was declared to know its scoping rules. GAH.
Not having to tell the compiler what kind of variable you are trying to use makes coding so much simpler. Not having to cast variables manually is a godsend. And this is considered a good thing to take away?
Reading further into this presentation, it's clear that the developer wants JavaScript to be Java. any<T>...? No no no no no no no.
Keep classes away from JS, unneeded complexity. Classes are inherently complex compared to the simplicity of prototypes. Classes sound like such a good idea, until you are knee deep in the inheritance chain trying to figure out where some method or attribute is defined and/or overwritten. They are one of the biggest reasons people need to use an IDE to write code.
Just learn JavaScript, guys. It'a a really simple language, just not like the ones you learned in university.
- olavk 12y ago> Block level scoping will introduce coding nightmares trying to figure out what scope your variable is in. I almost suspect you are trolling here. The variable is in scope inside the block in which it is declared. What could be simpler? With JavaScripts function-scoping, you can declare a variable inside a nested block, but it is still in scope outside and even before it is declared! And if you forget the "var" it is suddenly a global variable.
- seasoup 12y agoSure, forgetting the var causing a global variable is a problem, and I'd have no problem with removing variable hoisting and requiring all vars to be declared at the top of the function, it's what I do anyway. But adding a block level variable declaration just adds to the complexity of the language and doesn't add any real additional capabilities. It adds some nice fluff around loops and asynch operations, but that is all easily done using current scoping rules once you understand closures. var is still going to be around, but now we've added let. you might like let's scoping rules better then var's scoping rules, but now we'll have both. the interaction between the two is going to have some amazingly confusing and complex edge cases. If you think that hoisting and closures are confusing now, just wait until let is thrown into the mix as well. Even if let is simpler, var isn't going away. So we're just adding complexity to the system.
- olavk 12y agoI don't really see any edge cases in the interaction between let and var, can you provide an example? But yeah, using both var and let in the same function would be ugly. Probably you would want to stick with let in new code since there is no benefit to var over let. But obviously var has to remain in the language for backwards compatibility.
- seasoup 12y agoI haven't done a deep study on let to know how it interacts with var. Maybe it's something simple and I don't know it yet but how does this work: var foo = "abc"; function do ( foo ) { foo = "def"; console.log( foo ); let foo = "bar"; console.log( foo ); var foo = "baz"; console.log( foo ); } console.log( foo ); do( foo ); console.log( foo ); And of course var has to be around for backwards compatibility, but if the addition of let is being made to make variable declaration more intuitive or simpler then it is failing because var must be included. You cannot consider let in isolation and when considered in combination with var, it makes things more complicated.
- olavk 12y agoI would assume you get a compile-time error because you are declaring 'foo' twice. I guess you are right that the language is getting more complex because you are introducing a new way of declaring variables. However the added complexity in the language means you can write code which is less complex and error prone (if you consistently use 'let' instead of 'var'), and I think this is a fair trade-off given that backwards compatibility must be preserved.