News for hackers. Stuff that matters.
Re:How React, Vue, and Angular Work – Core Principles in One... by urduntupu on Thursday October 31, 2024 @04:38AM (#42004622)
The Vue/Angular demo files make use of `new Proxy()`. To the devs knowing these frameworks: is that best practice, or asked differently, are these representative examples?
Re:How React, Vue, and Angular Work – Core Principles in One... by Tade0 on Thursday October 31, 2024 @06:55AM (#42005505)
I think the author is trying to briefly show how internals of these frameworks are designed.

My framework of choice is Angular and the example is somewhat accurate, even if it shows just a small slice of the system.

Indeed Angular components start off with a compilation step (which doesn't have to be done entirely at runtime) and there's a system in place to react to data changes and events in the template - can't confirm whether it's using Proxies though.

But there's also a whole change detection system which reacts to event listeners firing, HTTP requests, timeouts etc. and decides which components to update and how.

Nowadays there are also signals, which add another layer on top of all that.

Overall Angular's internals are a massively complicated beast and few people have a good grasp of them (I've met some - would not recommend doing what they were doing). Net effect is that its development as a framework is slow. Personally I see it as a feature.

Re:How React, Vue, and Angular Work – Core Principles in One... by martypitt on Thursday October 31, 2024 @04:48AM (#42004676)
No, these aren't representative examples of how you would use Angular.

Angular code wouldn't use any of these techniques:

   - the use of Proxy()
   - calling compile(), 
   - using a querySelector to bind elements
   - Manually wiring up click handlers
But, I'm not sure that's what the author is trying to do -- I think they're trying to show what is going on under the hood, coded in pure JS.

In that context, it's probably relevant to show this (assuming it's indicative of what Angular actually does -- of that I'm less sure)

Re:How React, Vue, and Angular Work – Core Principles in One... by JimDabell on Thursday October 31, 2024 @04:44AM (#42004651)
Vue switched to proxies in v3. They haven’t had great browser support for a very long time, and if I remember correctly, polyfilling them was difficult.
Re:How React, Vue, and Angular Work – Core Principles in One... by whizzter on Thursday October 31, 2024 @04:57AM (#42004725)
Yeah, the Vue-like I made (other comment) was my second attempt at it and this time using just Proxy to simplify things. The first time I had tried to do it as Vue did previously with defineProperty but it was a damn mess to try to support arrays,etc and honestly the code was never stable (and using Vue V2 you can also run into a few edge-cases like missing properties missing reactivity).
Re:How React, Vue, and Angular Work – Core Principles in One... by wg0 on Thursday October 31, 2024 @10:02AM (#42007023)
Svelte 5 too.
Re:How React, Vue, and Angular Work – Core Principles in One... by throwitaway1123 on Thursday October 31, 2024 @10:34AM (#42007319)
Yeah Vue 2 used object getters and setters, and there were a few tricky caveats. For example, setting an array item using an index wouldn't trigger the setters (e.g. `myArray[0] = ''`). You had to remember these edge cases and use `Vue.set` [1]. Proxies made everything so much simpler, but they can't really be polyfilled at all, because they require deep JS engine integration (e.g. to register a callback that gets notified whenever a property is added to an object).

[1] https://v2.vuejs.org/v2/guide/reactivity.html

Re:How React, Vue, and Angular Work – Core Principles in One... by tobr on Thursday October 31, 2024 @04:50AM (#42004688)
Proxies work across all mainstream browsers. Only the rare IE holdout would be a problem.
Re:How React, Vue, and Angular Work – Core Principles in One... by yowzadave on Thursday October 31, 2024 @07:41AM (#42005795)
I have an old MacBook Air that my daughter uses for school; it doesn’t support the evergreen version of MacOS/Safari, or Firefox or Chrome. I think Proxies have been around long enough that they are supported…but I’m waiting for the day that she can no longer use a browser on that machine, at which point I’ll either have to buy her a new one, or install some flavor of Linux. It’s a shame because the computer itself is totally serviceable!
Re:How React, Vue, and Angular Work – Core Principles in One... by punduk on Thursday October 31, 2024 @06:29AM (#42005346)
There are probably still people here who use IE or browsers whose names no one remembers and only 3 people in the world use.
Re:How React, Vue, and Angular Work – Core Principles in One... by red_admiral on Thursday October 31, 2024 @07:15AM (#42005620)
Hey, elinks still works just fine inside tmux over an ssh connection. Less hassle than getting the VPN running correctly if I just want to read a company intranet wiki page.
Re:How React, Vue, and Angular Work – Core Principles in One... by Vinnl on Thursday October 31, 2024 @07:20AM (#42005652)
I'm fairly sure there are more people with various accessibility needs, so we can start worrying about those once everything is fully accessible.
Re:How React, Vue, and Angular Work – Core Principles in One... by exe34 on Thursday October 31, 2024 @06:42AM (#42005416)
it's the same three people though, and they're happy to support it themselves!
Re:How React, Vue, and Angular Work – Core Principles in One... by esperent on Thursday October 31, 2024 @06:47AM (#42005452)
Not sure why you're getting downvotes because you are correct.

https://caniuse.com/proxy