Live data from Hacker News

You don't need React: creating a minimal UI library in Vanilla JavaScript

pedroth.github.io

31–40 of 117 posts

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#31
post #7

> immediate mode You keep using that word. I do not think it means what you think it means. React most definitely falls under what would be called a "retained mode" of some sort. And the UI library described here is also.

I think the author is referring to immediate mode because of UI=f(state)

I do understand that's what they have in mind. But that's not what immediate mode means. Function application is not the only criteria.

We are talking about rendering into a browser by twiddling DOM APIs. That's definitely retained mode rendering and repeatedly claiming it's immediate mode doesn't make it true

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#32

Even this is more complex than many websites need to be. A few months ago I wrote about why I often create pages in pure html and css. https://joeldare.com/why-im-writing-pure-html-and-css-in-202...

Regarding small pages - there's a certain size threshold where the entire HTTP response is sent back in the first TCP window for most client OSes, which allows minimum round-trips.

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#35
post #32

Even this is more complex than many websites need to be. A few months ago I wrote about why I often create pages in pure html and css. https://joeldare.com/why-im-writing-pure-html-and-css-in-202...

Regarding small pages - there's a certain size threshold where the entire HTTP response is sent back in the first TCP window for most client OSes, which allows minimum round-trips.

Yes. You might be talking about the 14Kb problem.

https://joeldare.com/the-14kb-problem

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#36
post #4

> The only potential issue with immediate mode is performance, since we need to re-render the entire UI on every state change. How this made it to HN front page?

I think the author is saying a potential issue of a vanilla implementation of immediate mode. The following text explains that there is already many optimizations for this

"I think the author is saying" - Wait, are you not the author? This seems dishonest.

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#38
here is one that uses the fact that the raf loop will slow down when the tab is out of sync. makes state handling much easier. similar to dearimgui

frontend example https://github.com/spirobel/counter/blob/master/frontend/cou...

on the backend this obviously runs only once. the main issue with backend frameworks is, that the request and other context data has to be passed through the business logic + VIEWS. leads to tight coupling of all the components as it is downstream from the data structure + presentation

this is resolved by resolving the html template strings at the end and allowing functions (that also produce html template snippets) to be passed into the template strings.

this decouples views, business logic and data

https://github.com/spirobel/mininext/blob/master/docs/archit...

worked on this for the last few years. But it is still only a few hundred lines of code that you can understand in a few hours

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#39
post #4

> The only potential issue with immediate mode is performance, since we need to re-render the entire UI on every state change. How this made it to HN front page?

I think the high quality of the author's website is more relevant than theoretical concerns about performance.

Loading performance on the s website is quite good, and it appears to be using the JS library described in the blog post. I also saw that pages were loading around 60kb or JavaScript or less.

Also, from looking at the author's GitHub profile, it appears that they do not make significant use of LLMs and actually took the effort to write the code by themselves.

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#40
post #17

Earlier quoted context omitted.

Framework, not language. And framework choice still matters.

Tomato tomato. English is my favorite new programming language.

You're showing your ignorance here. Different frameworks have different ways of working that can lead to better or worse performance on client devices, no matter what Fable spits out for you. You owe it to your users to care.
Post reply on HN