3 ms·
I don't think mutability is JS design flaw. It was designed for manipulating UI - computer screen, which is mutable. If it was designed for printing (an immutab
by hatch_q 6y ago
I don't think mutability is JS design flaw. It was designed for manipulating UI - computer screen, which is mutable. If it was designed for printing (an immutable interface) i'd agree with you.
Bigger problem is that people started using javascript for server side, for which is (was) totally unfit for.
- dragonwriter 6y ago> I don't think mutability is JS design flaw. It was designed for manipulating UI - computer screen, which is mutable. You don't need, or particularly benefit from, language-level mutability to specify the next state of UI as a function of previous state plus new inputs, which is really the best way to model interactivity.
- throwaway189262 6y agoJS 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.
- hombre_fatal 6y agoThese 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.
- chasd00 6y agojavascript 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.