3 ms·
The DOM and built in libraries are of course terrible, but I really am talking about the language. Mainly it needs an object system where different programmers'
by WilliamLP 16y ago
The DOM and built in libraries are of course terrible, but I really am talking about the language. Mainly it needs an object system where different programmers' versions of objects can interact with each other easily and seamlessly in the same way. It also suffers badly from not having a real dictionary type. (Objects are slow, and checking for hasOwnProperty() is a pain in case you import something from someone who thought it was brilliant to extend the Object prototype.)
The magic 'this' parameter is a complete mess. Global scope by default for variables and no block scope is terrible, as is changing scope of variables from global to local if I later add a "var" version later on in the function. (Sure we should avoid global variables but they shouldn't be so easy and encouraged, without a real namespace system.)
Newlines acting like semicolons bites people a lot that I've seen as well. I hate the inconsistency in the object literal syntax. I need to quote the left side of them anyway, e.g. {"interface":"my-interface"} will break otherwise, so why not make it consistent and allow a variable, so I can pass {key: value} into a function requiring a dictionary? I also hate the inconsistency of keywords. Why can I redefine "undefined" and "NaN", but not "interface" or "super"?
Some of these are warts but not having an agreed on object system is a show stopper for general use, imo. Who rolls their own prototype system in Java? Nobody. Who rolls their own imitation of classical objects in JS? Most people.
- kragen 16y ago> Mainly it needs an object system where different programmers' versions of objects can interact with each other easily and seamlessly in the same way. It has one, as long as you don't need to inherit from other people's objects. But inheritance is a pretty poor way to compose code in most OO languages, especially single-inheritance ones like JavaScript and Java. > Who rolls their own prototype system in Java? Nobody. Who rolls their own imitation of classical objects in JS? Most people. Well, a few people. Mostly people familiar with class-based programming languages, which you are surely aware is a minority of the JS-programming population. One of the first things I did in Python was roll my own prototype system, actually. I really think you should organize your points better. There are some really serious flaws in there (the need for hasOwnProperty() and global-by-default) but you've mixed them indiscriminately with minor annoyances (keyword inconsistency, the absence of classes, no block scope).