Hacker News new | ask | show | jobs
by ZephyrBlu 1865 days ago
I'm very curious what the better, academic version of VDOM, hooks and components that has already been done looks like in comparison to React.
1 comments

Svelte does reactive UI without a VDOM at all. Every DOM operation flows from declarative instructions based on the state of the application, without a need for VDOM or hooks.

The compiler is quite mature and used by countless apps in production right now.

https://svelte.dev/

I've been using it myself and it doesn't feel academic at all. The Svelte Kit toolkit, a successor to the Sapper frameworks is also ready to use but it's not 1.0 yet so might be a bit unstable. But if you're worried about having to figure things out then you can use Sapper+Svelte or just Svelte just fine, and they're very robust and well documented.

I know what Svelte is. Svelte wasn't done before React or by "FP academics" though, which is what you said in the comment I replied to.
As I said, the VDOM was novel. However, unidirectional data flow, lenses and FRP with RxJs all predate React. There was also Elm which was a full framework that was based on these concepts, and ClojureScript with its whole ecosystem that did things a bit differently. Though most people who do utilise functional programming concepts prefer not to use a framework but pick-and-choose libraries that do the job for that specific project. That means that the field was (and is) very scattered, and there's no single "React but better and made earlier". Because React is a unique combination of tools. But each of those tools have been done in one form or another many times, except for the VDOM, which I believe was novel.

On another note, a React component in FP is just any regular old JS function with a signature: `(state) => HTML string`. React is such a simple concept that it wouldn't have needed any sort of library, if it weren't for the performance and DOM reset issues.

> However, unidirectional data flow, lenses and FRP with RxJs all predate React.

They may predate React, but React made them easy.

Good luck explaining how lenses work.

Rx? it took the author of RxJava months to understand the concept. And he had the author of Rx.net there to explain stuff to him. [1]

> there's no single "React but better and made earlier".

Yes. And that is precisely the point

[1] https://twitter.com/dmitriid/status/811561007504093184

Well that's why said

> React made a huge impact on web dev and deservingly so

The VDOM was revolutionary, no question about it. The comment I was replying to didn't even mention it.

Your original comment was literally this, emphasis mine:

--- start quote ---

All of these concepts are variations of what has been done before in a number of ways. Mostly by "FP academics" who "live in fantasy land", until everyone else starts using them too.

Transpiling, hooks and components have all been done (and done better) before React came along

--- end quote ---

When asked about the emphasized part, you mentioned Svelte for some reason. When called out on that, you went and listed a bunch of things, ... none of which are really better, and are quite esoteric. To the point that it took the authors of some implementations months to understand the concepts.

React (pre-hooks) could be picked up in less than a day, and just worked. Re-creating React concepts from scratch was a three-page tutorial.

I remember it a bit differently

for context, I wrote the first web frp+vdom and helped inspire the creation of rxLinq and related systems, and we even did a whacky thing back then that predicted Parse/Firebase/redux/graphql/falcor, including some basic features they still don't have (should have spun out a startup instead of getting a PhD!). our group even did the first lenses for the web, though that one ended up much less usable. I think we did all that around 2003, while the alternatives were PrototypeJS, jQuery, and a couple other more sugar-level things

however.... react with hooks, jsx, and the various css modes nowadays is pretty awesome, and eliminates most of the needs for streams. main lack there is more for rich animation, than web apps. graphql, redux, and friends are all still clearly clunky technologies with limited shelf lives, so I'd focus more there than react for basic abstractions

at the same time, nowadays I think more about synthesis, ml, end-to-end GPU computing (actually proposed that back then too!) and other more powerful ideas than revisiting frp/lenses/etc...

Then I stand corrected. :) Maybe I wasn't looking hard enough earlier.
How is the vdom novel? Any retention mode GUI does that, hell the DOM itself does that. It’s only novel in that they reimplemented it in “user-land”, because of the performance shortcoming of the DOM.
It was novel because you couldn't refresh the whole DOM based on your application state without user experience suffering, before VDOM diffing came along.
And they still had to execute the DOM operations anyway so I feel scepticism of React was warranted.

When the complex reality of JS applications was reached in React, React shortcoming became more and more apparent.

There's no free lunch.

The easier to mentally digest appeal of 'redraw the whole thing every-time'* was fantastic but performance was always going to take a massive hit past an easily reached point.

* The difference this time was the diff engine was going to be smarter than before but it was not good enough.

> all predate React. There was also Elm

No, React was first. It was in production, if internally, for more than a year before Elm came onto the scene.