3 ms·
The DOM has double impedance mismatch written into its most basic foundations. It's an object oriented API to something that functional programming is much bett
by jerf 5y ago
The DOM has double impedance mismatch written into its most basic foundations. It's an object oriented API to something that functional programming is much better for (functional programming loves manipulating trees recursively). And then, you're using Javascript to program it, a dynamic scripting language, but the DOM spec is heavily biased towards static C++ or Java, thus it simultaneously fails to take good advantage of the opportunities a dynamic language offers while also importing the verbosity and hoop jumping of 1990s statically-typed programming... and statically-typed programming has come a long way since then!
You can see this most clearly in DOM 1.0: https://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html https://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-on... Look particularly at the "IDL specifications". That's Java, not Javascript!
Later versions have improved various elements of this, but the fundamental architecture is still there and still not looking much like what I would write down if I wanted to write out a similar system natively for Javascript, assuming this was still the 1990s and that meant I could also modify JS itself a bit.
When you learn how to work around these impedance mismatches you can do some good work, but the resulting code may not make much sense to your coworker. Fortunately, even in native JS nowadays, .querySelector and similar APIs make it unnecessary to have to "walk" the DOM much anymore.
I'd even argue you could cite the existence of a triple mismatch, in that the original DOM level 0, supported in Netscape 2.0, entirely precedes the idea of a writable DOM. (It wasn't until Netscape 4 that we got "layers", which were useless, and it was IE 4 that finally gave us manipulable DOMs as we know them today. [1]) So the standard that was originally written with the concept of introspection and largely read-only access (you could only write things that the browser could guarantee wouldn't require a reflow, and not necessarily all of those) got a lot of write access bodge onto it later.
Historically, it's a huge mess.
[1]: They didn't necessarily work the way we expect today for much longer than that, I crashed IE 4 a lot with stuff we'd consider trivial today, but it was the first browser to at least try presenting everything in the DOM as editable.
- austincheney 5y agoIt sounds like you are looking at anything you can find, grasping at straws, to rationalize insanity. So much of what you described is absent in the Level 2 and Level 3 specifications. This is clear when your reasoning only makes sense using a 23 year old expired snapshot for an evolving technology that remains the backbone of frontend technology today. * https://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ https://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ * https://www.w3.org/TR/DOM-Level-3-Core/ https://www.w3.org/TR/DOM-Level-3-Core/ The DOM is a language agnostic API written without any particular programming languages in mind and written to simultaneously and universally support both HTML and XML Schema. These are stylistic and organizational concerns still not enough to qualify the irrational behaviors favoring jumping off a bridge. This is concerning considering learning to use the concepts takes substantially less time than learning the APIs of modern JavaScript frameworks developers favor. There remains far more to this that is psychologically focused regardless of any technology.
- jerf 5y agoTechnologies maintaining reverse compatibility always contain echos of their beginnings. History matters. We still live with those wrong foundations chosen at the beginning. But if you just want to blame almost all developers everywhere across several decades for mysteriously being unwilling to engage with a simple and wonderful technology that has no flaws, feel free. It's easy, but it leads to no further understanding or wisdom.
- austincheney 5y agoBlaming the technology is not sufficient to explain the behavior. Ignoring that and putting your head in the sand isn’t an indicator of wisdom. http://www.fallacyfiles.org/bandwagn.html http://www.fallacyfiles.org/bandwagn.html