←back to thread

218 points mdhb | 2 comments | | HN request time: 0.516s | source
Show context
austin-cheney ◴[] No.44393968[source]
DOM templating is just like JavaScript classes. Classes in JavaScript were requested since the earliest of times and always rejected until ES6 (2014), because they are/were:

* always unnecessary

* always artificial

* only vanity

* only desired by insecure persons not familiar in the technology

* only qualified as bad idea but necessary because people were just going to do it anyways

So far the DOM has managed to escape this stupidity only because it is not a part of JavaScript. Java people ignorant of JavaScript desirous of features to make JavaScript feel more like Java has no bearing on the DOM, for example, because they are separate technologies managed by unrelated organizations.

None of the ergonomic reasoning mentioned in the article are qualified. Just because many people lack confidence in the technology and knowingly make poor design decisions doesn’t mean a familiar vanity layer will fix anything. Declarative comfort, for example, is not a resolution to performance and security problems just because other knowingly bad design decisions are worse. Two wrongs don’t make a right.

Furthermore the DOM already has a slow unnecessary declarative abstraction layer insecure people cannot live without called querySelectors. In other words this proposal is to React as querySelectors are to jquery, and classes are to Java. These are/were trends and trends die over time. We really should move past vanity as an alternative to an absence of training.

replies(2): >>44397447 #>>44400388 #
yoz-y ◴[] No.44400388[source]
I’m curious. What is actually wrong with querySelector?
replies(1): >>44401247 #
1. austin-cheney ◴[] No.44401247[source]
String interpolation is so ridiculously slow. Epic slow.

Perhaps just as importantly is that is a crutch for many to avoid accessing the DOM in steps. You can read from the DOM with querySelectors but you cannot modify the DOM with them. If querySelectors is all you can do then you must use some third party template system because you have no idea how any of this works even though it provides maximal expressive freedom.

replies(1): >>44409025 #
2. yoz-y ◴[] No.44409025[source]
Is anything preventing JS from compiling the proper stepwise dom access if the querySelector parameter is a literal? That would basically push the interpolation into the parsing step.