News for hackers. Stuff that matters.
Re:JavaScript Is Weird by wruza on Monday June 28, 2021 @07:49AM (#27660622)
Trash

“Admitting like this has a bunch of quirks, but it’s still great.” (not arguing for it though)

Criticism is a driving force behind change to the better. Calling something “great” without pointing out great sides I find… pointless and harmful.

To name a few great points, distinct from other languages:

JS has a pretty shameless object model, where you (usually) have ordered keys, and every key is a property with an {enumerable, writable, configurable, get, set} descriptor. It is much more usable and practical than in almost all other languages. (They do that for “efficiency”, but that’s non-sequitur)

JS has very useful destructuring syntax, which many languages lack of and that leads to assignment bloating and boredom. Also, jit optimizes out temporary objects, so foo({x, y}) / function foo({x, y}) works almost at the same speed as foo(x, y).

JS has a nice Function type, which allows easier metaprogramming and substitution of ‘this’ object. Functions are objects, so you can function foo() {}; foo.x = 1; console.log(foo.name, foo.x).

JS bare objects may have methods and properties: t={_x:1, get_x(){return this._x}, …}

JS doesn’t treat syntactic lists in a last-value-only way, so you can expect foo(…a, …b, c) to work, and to work as intended. E.g. Lua cannot do that, and python (afair) requires you to collect items into a single array (not sure, correct me if I’m wrong).

But what people usually mean by “great” is “it generally works”. I know it is an american thing, but some aspects of js, including those you meet everyday, are really just trashy. It would be nice to not have them at all.

There are no comments on this comment yet.