Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JS just has a very simple, flawed design. It's still a rather bad language from a design perspective.

One of the shortcuts is that all objects are hashmaps. Fully mutable hashmaps with string keys. You can do this:

obj.prop = "hi"; obj["prop"] = "bye";

And you set the same field. And you can do that to any object, reassigning any field type.

Most languages have static number of fields in an object, or at least static types for fields already created.

Another huge shortcoming is prototype chain based inheritance. Someone can rewrite a random link in your chain and suddenly you have another object type entirely. It's also very bad for performance. Essentially, the inheritance tree of an object can change at runtime.



These are more like footguns for beginners than intractable obstacles. For example, you can avoid the issues in your comment with static analysis (Typescript). And the Javascript professional just avoids things like arbitrary obj[prop] and prototype chain hacking.

And since they aren't intractable, and smart people regularly decide that it's worth the downsides, you're making the uninteresting observation that $lang has warts.


javascript gets a lot of heat from folks wishing it was a different language. It's just different, works differently, does things atypical of most languages. You can fight it or learn it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: