Live data from Hacker News

What dif­fer­enti­ates front-end frame­works

themer.dev

171–180 of 256 posts

Re: What dif­fer­enti­ates front-end frame­works

#171

> To overcome the shortcomings of the default change detection paradigm, the Angular team is working on a new approach called Signals. Conceptually, signals are similar to Svelte stores (which we’ll get to later), and fundamentally, they solve the change detection problem the same way as React; the framework is taking control over the application’s state so that changes can be easily monitored and re-renders can be a…

Signals have their own shortcomings as well. Once you leave the "re-run the render function on state change" you suddenly are dealing with implicit dependencies, stale closures, cyclical updating, and all sorts of weirdness in debugging things, figuring out what triggered what, etc. Signals as a concept existed well before React and I think part of the genius of React is actually not using them. In a way a signal is…

> I think part of the genius of React is actually not using [signals]

Except that with the introduction of hooks (aka "OCaml 5.0 effects, but in JS, as a UI framework") you get some of the same interesting issues cropping up in React codebases as well, just spelled differently (stale closures, implicit dependencies, weird debugging issues)

Re: What dif­fer­enti­ates front-end frame­works

#172
post #150

Earlier quoted context omitted.

>> Or did I misunderstand your comment? Well, I can see now that while I expressed my dislike for change detection I didn't paint a good picture of why I think we'd be better off without it :-). While I appreciate React's declarative programming style I dislike the fact that React (and all the change-detecting alternatives) force me to interact with the DOM through their APIs. JQuery allowed me to do whatever the hel…

I‘ve written a UI a few months ago with only lithtml and direct DOM manipulation and it worked pretty well. I needed to do calculations and reading bounding boxes from the DOM initially and on resize. Basically a hack to get around CSS limitations. It was crucial that this is fast enough to avoid flickering. I wouldn’t have attempted this with react. I think it would still be possible with useEffect, but I tried the…

in the cljs/reagent world anytime you need to do direct dom stuff you just use a ref - that must me the same for react proper?

Re: What dif­fer­enti­ates front-end frame­works

#173

QML wins with bindings and signal and slots! (In this example the the text property of the Text componenet is binded to count , so whenever count changes the text changes). ``` property int count: 0 Button { onClicked: { count--; } } Text { text: count.toString(); } Button { onClicked: { count--; } } Button { onClicked: { incrementLater.start(); } } Timer { id:incrementLater interval: 1000 onTriggered: { count++; } }…

Having used both QML and Svelte, I enjoy Svelte a lot more. The reactive APIs are very similar, just declare variables, mutate them, and use them. But Svelte is much nicer for many reasons: 1. It uses modern JavaScript and not some limited custom ES5-like JavaScript 2. Svelte can be used with TypeScript so your UI code can be statically typed 3. The integration with Svelte and VSCode is much better than QML and Qt Cr…

how would the above QML example be implemented in svelte?

Re: What dif­fer­enti­ates front-end frame­works

#174

Totally disagree with this. Change detection is nothing but a hack to get around the fact that interacting directly with the browser DOM is very slow and blinky. Imagine a world where interacting directly with the browser DOM didn't suck, then none of these libraries would exist. The crux of the problem is that the browser immediately reflects changes to the DOM to the screen. And when you make a bunch of changes to…

Engineers developing rendering engines for browsers definitely know what double buffering is. However, the accumulation of peculiar layout rules, support for CSS, and many other things make things hard. One of the major design flaws of the DOM was allowing unrestricted mutability. If DOM mutations were transactional by default, it would offer better control over layout reflows.

Change detection remains a common UI issue, even in native UIs. While rerendering everything on each UI loop is possible, as complexity increases, optimizations involve detecting changes. Smalltalk introduced MVC to identify changes and update the UI. Java Swing and Qt also adopted similar mechanisms with different names (observers, signals, and slots). Apple's Cocoa employs a variant of MVC as well. Change detection has historically been a common problem even in Win APIs.

Re: What dif­fer­enti­ates front-end frame­works

#175

Earlier quoted context omitted.

Signals have their own shortcomings as well. Once you leave the "re-run the render function on state change" you suddenly are dealing with implicit dependencies, stale closures, cyclical updating, and all sorts of weirdness in debugging things, figuring out what triggered what, etc. Signals as a concept existed well before React and I think part of the genius of React is actually not using them. In a way a signal is…

> I think part of the genius of React is actually not using [signals] Except that with the introduction of hooks (aka "OCaml 5.0 effects, but in JS, as a UI framework") you get some of the same interesting issues cropping up in React codebases as well, just spelled differently (stale closures, implicit dependencies, weird debugging issues)

Well you get explicit dependencies which have ups and downs, but closures do become an issue. That said, I find hooks less magical and less prone to cycles, especially as you're staying with a top down data flow generally.

Re: What dif­fer­enti­ates front-end frame­works

#176
Why can't we just use Model-View-Controller for change-detection?

Views subscribe with the model to get notifications about changes to different "aspects" of the model. When they get a change-notification they update themselves by asking the model for its latest data for a given aspect.

Re: What dif­fer­enti­ates front-end frame­works

#177
post #173

Earlier quoted context omitted.

Having used both QML and Svelte, I enjoy Svelte a lot more. The reactive APIs are very similar, just declare variables, mutate them, and use them. But Svelte is much nicer for many reasons: 1. It uses modern JavaScript and not some limited custom ES5-like JavaScript 2. Svelte can be used with TypeScript so your UI code can be statically typed 3. The integration with Svelte and VSCode is much better than QML and Qt Cr…

how would the above QML example be implemented in svelte?

This QML example is implementing the example from the article, and the article already implements this example in Svelte. However, the Svelte implementation becomes even more concise when you inline the functions:

  
   let count = 0
  
  
  count--}>decrement
  {count}
  count++}>increment
  setTimeout(()=>count++, 1000)}>
   increment later
  
Play with this in the Svelte REPL here: https://svelte.dev/repl/97d42ad98e4b4a929d3c5a3de880e6fc?ver...

Doing this, I also realized rubymamis cheated a good bit on their QML version. It's missing the text for the buttons. It's not wrapped in `ApplicationWindow { }`. And there's a bug with their implementation: If you clicked their "increment later" button many times quickly then it would keep resetting the timer and only increment once.

Re: What dif­fer­enti­ates front-end frame­works

#178
post #16

React is not reactive at all, the "state" management is you calling a function "setState" to re-render the component. And I find manual render very usefull and once you do it, you can have a global state as simple as a global object, no need to use useState anymore. https://github.com/dezmou/useRender

The reactive part is every component getting that prop will update versus needing to write a function in jQuery to manually update the inner HTML of those components

Re: What dif­fer­enti­ates front-end frame­works

#179
Perhaps adrift a bit of the main topic, but curious if anyone with more than cursory experience with any of the mainstream browser front end frameworks and JavaFX could briefly compare and contrast them.

I do not consider myself a front end person, but I’m slowly getting more adept with FX, more so as a hobbyist than professional, but have no experience with the browser systems.

Re: What dif­fer­enti­ates front-end frame­works

#180

> To overcome the shortcomings of the default change detection paradigm, the Angular team is working on a new approach called Signals. Conceptually, signals are similar to Svelte stores (which we’ll get to later), and fundamentally, they solve the change detection problem the same way as React; the framework is taking control over the application’s state so that changes can be easily monitored and re-renders can be a…

[deleted]
Post reply on HN