Earlier quoted context omitted.
This relieves the developer of keeping track of DOM state, as you only declare the render function once A good part. and after that you only need to manage state A part where to change a[n].b.c: React: you either split into unhealthy number of “components”, which are never reused and require tons of pass-through, or only manage state as a sequence of unnatural to js “reduce” operations. Vue: give away your data to Vu…
You have to manage state within the rules of the framework, that's true. But the hard part of programming usually isn't syntax. Who cares if it's a different language/paradigm? It's a simple language and I only have to say a few words. It's still orders of magnitude less complex (this is not an exaggeration) than rolling your own framework with vanilla JS. I would encourage you to find out why React is popular and wh…
TodoMVC App Written in Vanilla JavaScript
111–115 of 115 posts
Re: TodoMVC App Written in Vanilla JavaScript
#112The thing I enjoy about frameworks like React is the declarative nature of the UIs. I'd love to not be able to use them and to create complex UIs in pure JavaScript but it always ends up being painful where you spend more time optimising the rendering than doing any work. In simple apps I will write UI in a functional matter in pure JavaScript, regardless of the performance implications. But bigger DOM means worse pe…
Echoes of Alan Kay's recent comment on how software devs are way too concerned with the how the computer works to the detriment of what the software is supposed to do.
Re: TodoMVC App Written in Vanilla JavaScript
#113Earlier quoted context omitted.
Echoes of Alan Kay's recent comment on how software devs are way too concerned with the how the computer works to the detriment of what the software is supposed to do.
Yup. The reality is that programmer time is far far more expensive than compute time. And as long as that's the case, increasing levels of abstraction are our only hope at building complex software.
Re: TodoMVC App Written in Vanilla JavaScript
#114Wouldn't this have loads of memory leaks from never removing the event listeners when the todo elements go away? I think it hides the complexity by pretending that's not a problem
The event listeners get cleaned up by the GC. At least in modern browsers. While events aren’t explicitly mentioned, MDN offers an insightful read: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memo... Alternately, one can use event delegation [0]. As does React under the hood [1]. 0 - https://javascript.info/event-delegation 1 - https://reactjs.org/blog/2020/08/10/react-v17-rc.html#change...
Also the browser doesn't make a distinction to the type of event (such as `click` ), and say "Oh well you can't click on an element not in the DOM, I think I can clean this up"
So no it will not clean it up and it will leak memory, see for yourself
Re: TodoMVC App Written in Vanilla JavaScript
#115Earlier quoted context omitted.
The event listeners get cleaned up by the GC. At least in modern browsers. While events aren’t explicitly mentioned, MDN offers an insightful read: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memo... Alternately, one can use event delegation [0]. As does React under the hood [1]. 0 - https://javascript.info/event-delegation 1 - https://reactjs.org/blog/2020/08/10/react-v17-rc.html#change...
I think there's a reason why events are not mentioned in your linked document... The reference is maintained in memory because the browser has no idea if you will be using it again. After creating the listener, you may very well append it to another element later for all the browser knows. Also the browser doesn't make a distinction to the type of event (such as `click` ), and say "Oh well you can't click on an eleme…