Wrong. What makes it powerful is its ubiquity and the fact that it's de facto the only game in town for browser behavior scripting.
Want a constant? Make a global variable and don't change it.
That involved mental overhead (and team co-ordination) that makes it far less simple than "const foo".
Scope in JS is very simple to understand
Simple != intuitive or less prone to bugs. Brainfuck is also simple to understand, just a handful of rules. I wouldn't want to program in it, though...
One of the strengths of js is that every thing is an object(almost). So the bit about "no more need to abuse objects as dictionaries" is a bit odd. Since most things are objects, you get the power to treat functions, types, literals, etc in interesting ways.
Yeah, the only thing you DON'T get is an actual dictionary. Without hidden values coming from prototype, without reserved words, etc.
This proposals retains all that power PLUS gives you an actual bloody dictionary, one of the three more basic data structures in all of programming, without the toil and the million edge cases objects as dicts have.
For me, I almost never use == so it should be gotten rid of.
So what you consider as strengths are the shortcomings, and what you consider as a problem is an actual case that it can be considered a neat feature. The way js is designed, "==" makes more sense, because it lets you use more dynamic equality checking.
Wrong. What makes JavaScript popular is how good it is. You can't explain its mass popularity growth in non browser setting (node js ) with its ubiquity. It is a great language, and perhaps ubiquity was needed to get a lot of people to try out new concepts.
Have you used Javascript? I mean to do real-web apps, not to enhance some webpages with a bit of JQuery (as useful as that is).
Var is broken in js because it does not obey sensible semantics
for(var i....
does what you think it does. In every language except javascript it would declare i only inside the loop. In js it declares i in whatever function scope the loop is inside.
A = function(){
console.log(this);
}
A.prototype.q = function(b){
this.h = b;
}
imp = new A();
setTimeout(100, imp.q)
//later, in a response to a user event
console.log(imp.h)
prints undefined. Why? because in Javascript the value of this changes. There is literally no other language where this is dynamically (as opposed to lexically) scoped.
Don't even get me started on the lack of ints, the lack of static types (which means your IDEs suck).
As for why node decieded to go with js? No idea, though it is one of the things I hate most about node. Haskell would have been a better choice, as would Lua.
> Var is broken in js because it does not obey sensible semantics
Scoping is broken in pretty much all modern dynamic languages.
Take Ruby for example:
i = 10
[1, 2, 3].map{|i| i * 3}
[1, 2, 3].map{|j| j * 3}
puts i # prints 3
puts j # raises undefined local variable
Or let's look at Python:
def maybe_append(b=[], n = None):
if not n is None: b.append(n)
return b
print maybe_append(n=20) # prints [20]
print maybe_append(n=30) # prints [20, 30]
So there's only a single instance of [], so that the default argument "grows" over time.
Your argument makes it pretty clear it is you that have not used Javascript very much.
setTimeout( 100, imp.q) // DOESN'T DO ANYTHING, 100 is not a function
And if you thought about it for more than a few seconds, you would realize that the behavior of "this" makes sense and is less magical than in other languages. Since "imp.q" is not a function call, it is a reference to a function, you are simply passing in a function. Since javascript "classes" are just objects with function references, you can't somehow decide what object "this" should point at unless it is explicit. In the case of "foo.bar()", it is explicitly "foo". In the case of setTimeout( foo.bar, 100), all setTimeout gets is a function pointer with no notion of what this should be.
Anyway, the rest of your gripes just sound like you don't like untyped languages, which is personal preference and I guess I don't share your preference.
I haven't used setTimeout much, but I do use js everyday (it is my fulltime job).
And it may be nice to have 'just objects with function references' when you are writting a few lines of code to validate emails or something like than. When you start pushing 2k lines of code and more than two developers you need much more structure than than that. Anyhow C++, Scala and C# all have reasonable understanding of this. If all you have are function points, don't have this.
Hah, no reason to get defensive. Javascript is a great language. If you don't like it, you are free to feel that way. But there is a huge number of people who like it. Personally, it is my favorite programming language. It just feels right.
And I've only been using it for a few years. It really isn't hard to get past the bad parts.
Wrong. What makes JavaScript popular is how good it is. You can't explain its mass popularity growth in non browser setting (node js ) with its ubiquity.
Sure you can. Node.js is not even that impressive: similar solutions exist in lots of other languages, Ruby, Python, even Java. The Node guy wrote Node in JS for two reasons: V8 was a good and fast environment, and JS didn't have much existing libraries, so people could start making new async libs.
Wrong. What makes it powerful is its ubiquity and the fact that it's de facto the only game in town for browser behavior scripting.
Want a constant? Make a global variable and don't change it.
That involved mental overhead (and team co-ordination) that makes it far less simple than "const foo".
Scope in JS is very simple to understand
Simple != intuitive or less prone to bugs. Brainfuck is also simple to understand, just a handful of rules. I wouldn't want to program in it, though...
One of the strengths of js is that every thing is an object(almost). So the bit about "no more need to abuse objects as dictionaries" is a bit odd. Since most things are objects, you get the power to treat functions, types, literals, etc in interesting ways.
Yeah, the only thing you DON'T get is an actual dictionary. Without hidden values coming from prototype, without reserved words, etc.
This proposals retains all that power PLUS gives you an actual bloody dictionary, one of the three more basic data structures in all of programming, without the toil and the million edge cases objects as dicts have.
For me, I almost never use == so it should be gotten rid of.
So what you consider as strengths are the shortcomings, and what you consider as a problem is an actual case that it can be considered a neat feature. The way js is designed, "==" makes more sense, because it lets you use more dynamic equality checking.