3 ms·
Because it's kind of right, in the way that it's not technically accurate, but a bit of an approximation that's reasonable for a beginner-level introduction.
by matthewmacleod 8y ago
Because it's kind of right, in the way that it's not technically accurate, but a bit of an approximation that's reasonable for a beginner-level introduction.
- azangru 8y agoBut how, how? I wouldn't be able to bring myself to say something that I knew to be strictly inaccurate. Even if you are talking to beginners, don't you owe it to them to say only things that you believe to be true? There are lots of ways to put it differently so that it wouldn't be so outrageously inaccurate and so that, if you are a beginner, more senior developers don't laugh at you if you repeat those things.
- matthewmacleod 8y agoIt's not that inaccurate. It's in the right ballpark, just glossing over all of the details of what that means in practice. Would you prefer "The virtual DOM helps make React work a lot faster than doing direct manipulation of the DOM using vanilla Javascript"? Doesn't really seem like it makes that much difference – and the author links to an external video that explains it all in more detail. Anyway, any senior developer who laughs at a less experienced one for repeating that kind of thing is a bad developer. I'd like to think they'd take the time to correct the inaccuracy :)
- azangru 8y ago> Would you prefer "The virtual DOM helps make React work a lot faster than doing direct manipulation of the DOM using vanilla Javascript"? I am not sure this is even correct. Firstly, the famous js framework benchmarks (https://github.com/krausest/js-framework-benchmark https://github.com/krausest/js-framework-benchmark) based on adding/removing list items used to have vanilla JS as an unbeatable winner, despite its direct manipulation of the DOM, and React was definitely significantly behind. Secondly, as the README for morphdom says, the real DOM is very fast (https://github.com/patrick-steele-idem/morphdom https://github.com/patrick-steele-idem/morphdom). If I remember correctly, virtual DOM was supposed to solve the particular performance problem where you would otherwise just throw huge chunks of DOM away rerendering them anew every time your app state changed. But this is a very special (although brilliant) approach to keeping your UI in sync with your app state; you wouldn't necessarily do so if you wrote your app with vanilla JS.
- azangru 8y agoOh, I am sorry, I re-read your sentence, and I think I misunderstood it. Yes, if React were using real DOM rather than virtual DOM it would have been slower, but the author was not trying to make _that_ point.
- tracker1 8y agoSometimes it's easier to brush off a question, or make a statement in a learning context than get tied up in nuances. Do you really want to learn react with a 4-hour video on framework comparisons in the middle before you've learned the one you're looking at?
- azangru 8y agoI'm just saying that there are more valid selling points for React than speed.
- bobziroll 8y agoIt's a valid point - if I were concerned that Jr. developers would parrot every line from the course to the ridicule of very particular Sr. developers I would have specified that the Virtual DOM makes React faster than if it were trying to directly use the actual DOM, all else being equal. But since that wasn't a concern of mine when I made that video (it is far from the main takeaway of the course), I kept it as simple as it needed to be to get the point across.
- azangru 8y agoBut why even bring up the topic of virtual DOM in a course addressed at beginners? If you picture your target audience as so new to the field, why should they even care how React is working under the hood to change the contents of the screen? Virtual DOM (unless I am mistaken) is a solution to the problem that React would have otherwise introduced. But surely, selling points of a framework are not how it solves its own technical problems, but rather what problems it undertakes to solve for its user.