←back to thread

218 points mdhb | 3 comments | | HN request time: 0.758s | source
Show context
d--b ◴[] No.44393198[source]
The part about Signals is telling and illustrates well why the idea while laudable is practically unfeasible.

I get why OP likes signals. In every large enough project there is a half baked implementation of a DAG calc tree and it makes sense that a language could standardize one.

But these abstractions have a huge mental / implementation cost.

The problem, as with most engineering things is a tradeoff problem. The react model - where you just update the global state and re-render everything - is slower but easier on the brain. The signals model is faster, but so much effort.

Most apps out there don’t need to be crazy fast, and people will choose react because it’s just simpler.

But signals don’t really have anything to do with templating, do they? So why do we have to choose, could we have templating and signals as separate things?

Well OP thought about templating and realized you do need a way to tell the dom how to fit your templated node where it belongs and update it when things change.

And this is where these proposals fail. There needs to be a choice here. The API must pick a side (well technically it could allow for both, but ugh), and developers won’t ever agree which side it should go.

The big problem of UIs has always been how they update, not how they’re defined. Microsoft tried (and failed) at defining a ton of models, MVC, MVP, MVVM, and what not, all of them were painful AF. Then imgui come and say, well what if UIs didn’t have state at all. Ooh this is nice, but kind of hard on the cpu, so what do we do?

Well, perhaps one of the biggest reason for the success of web apps is in fact that the dom didn’t impose a way to bind data to its view. And so we may be doomed to framework hell.

replies(3): >>44393219 #>>44393405 #>>44394194 #
leeoniya ◴[] No.44393405[source]
> The react model - where you just update the global state and re-render everything - is slower but easier on the brain. The signals model is faster, but so much effort.

there are multiple frameworks now that do fine-grained diffing without relying on signals, proxies, or any other reactive primitives. they basically have the top-down react model but much faster and without the weird concepts like hooks and manual/wasteful dependency arrays.

my favorite one is ivi-js: https://github.com/localvoid/ivi

it's just 8% slower than the fastest / ugliest / imperative / unmaintainable vanilla js you can eventually arrive at if all you care about is winning benchmarks.

https://krausest.github.io/js-framework-benchmark/2025/table...

replies(1): >>44394080 #
localvoid ◴[] No.44394080[source]
Just want to add that even though ivi is using tagged templates, I am strongly against using tagged templates to describe UIs as a Web Standard.

One of the most useful features that could make a lot of incremental computation problems easier is "value types"[1], but unfortunately it seems that isn't going to happen anytime soon. The biggest constraint when developing an efficient UI framework with good DX is JavaScript. Also, it would be nice to have `Node.prototype.insertAfter()` :)

1. https://github.com/tc39/proposal-record-tuple

replies(1): >>44395499 #
leeoniya ◴[] No.44395499[source]
> The biggest constraint when developing an efficient UI framework with good DX is JavaScript.

for perf, s/JavaScript/DOM, i think.

good DX comes from ecosystem and amount of time invested in making good tooling. JSX would be a non-starter without IDEs helping autocomplete, linting/format, syntax coloring, and webpack/babel to do the compilation.

tagged templates could reach at least the same level of DX as JSX if the community invested the resources to make that better. i'm not saying it's the right solution for a standard, but it would be way better than jsx, since tagged templates are already a standard.

replies(2): >>44395787 #>>44396880 #
troupo ◴[] No.44395787[source]
> JSX would be a non-starter without IDEs helping autocomplete, linting/format, syntax coloring, and webpack/babel to do the compilation.

and then you immediately go on to say this:

> tagged templates could reach at least the same level of DX as JSX if the community invested the resources to make that better.

So, tagged templates are also non-starters without IDEs helping autocomplete, linting/format, syntax coloring.

> i'm not saying it's the right solution for a standard, but it would be way better than jsx, since tagged templates are already a standard.

They are strings. There's no magic in tagged templates that somehow make them immediately better for some custom non-standard syntax compared to JSX.

You can't just plop a string containing lit's custom non-standard syntax into an IDE (or a browser) and expect it to just work because "it's tagged templates are standard".

For the purpose of templating in the browser there's literally no difference between standardizing a custom syntax based with JSX or tagged templates.

replies(1): >>44396059 #
leeoniya ◴[] No.44396059[source]
> There's no magic in tagged templates that somehow make them immediately better for some custom non-standard syntax compared to JSX.

they're marginally better since they have a platform-defined way to deliniate static from dynamic parts. ivi _can_ work without a runtime or build-time JS parser, while JSX cannot (because jsx has to be parsed out of full blobs of js)

on the dx/ide side, sure there's not a huge amount of difference if both had the same effort invested.

replies(1): >>44396945 #
1. troupo ◴[] No.44396945[source]
In the context of "let's create a native templating syntax for the browser" those differences between JSX and tagged templates don't matter. You still need something that the browser needs to parse and understand, you still need something for libs/frameworks to handle/understand/compile to.

My feeling is that tagged templates would actually be a worse fit in this scenario because now you would have to distinguish between "regular" tagged templates and "templating" tag templates.

replies(1): >>44397145 #
2. localvoid ◴[] No.44397145[source]
If I understand it correctly, the main argument in favor of tagged templates is that it doesn't require any changes to the js engine and that is why it will be way much easier to push forward. Browser implementation should be quite straightforward and it will be possible to implement a semi-efficient polyfill.

Personally, I don't think that it will have any significant impact, everyone will continue using React,Vue,Svelte and it is highly unlikely that they are going to adapt this new API.

replies(1): >>44398135 #
3. leeoniya ◴[] No.44398135[source]
that's a better distillation :)