Live data from Hacker News

Datastar: Web Framework for the Future?

chrismalek.me

31–40 of 161 posts

Re: Datastar: Web Framework for the Future?

#31

If you want a solid demo of what you can do with datastar. You can checkout this naive multiplayer game of life I wrote earlier in the week. Sends down 2500 divs every 200ms to all connected cliends via compressed SSE. https://example.andersmurphy.com/

"Sends down 2500 divs every 200ms to all connected cliends via compressed SSE."

If I didn't know better, I'd say this was an April Fool's joke.

Re: Datastar: Web Framework for the Future?

#32

If you want a solid demo of what you can do with datastar. You can checkout this naive multiplayer game of life I wrote earlier in the week. Sends down 2500 divs every 200ms to all connected cliends via compressed SSE. https://example.andersmurphy.com/

Is sending 10,000 divs/sec the right solution for this problem, or is this an "everything looks like a nail" solution?

It's deliberately naive. But brotli and a tuned compression window over SSE means it gets 150-250:1 compression ratio, combined with Datastar rendering speed and you can get away with it.

The reason it's naive is although you can use datastar to drive SVG, a canvas or even a game engine the minute you do people think you are doing magic game dev sorcery and dismiss your demo. I wanted to show that your average crud app with a bunch of divs is going to do just fine.

I break it down in this post.

https://andersmurphy.com/2025/04/07/clojure-realtime-collabo...

Re: Datastar: Web Framework for the Future?

#33

If you want a solid demo of what you can do with datastar. You can checkout this naive multiplayer game of life I wrote earlier in the week. Sends down 2500 divs every 200ms to all connected cliends via compressed SSE. https://example.andersmurphy.com/

Is sending 10,000 divs/sec the right solution for this problem, or is this an "everything looks like a nail" solution?

This is a Wirth's Law solution - the reasoning goes: "computers are fast enough to deal with it, so why not?"

Re: Datastar: Web Framework for the Future?

#34
post #3
post #2

The TODOS mini application at data-star.dev is slow and doesn't work correctly for me (checking/unchecking items isn't reliable). To me, this highlights one common problem I've seen with frameworks that insist on doing everything on the server.

Agreed, I have gig internet and a hardwire connection and still get more lag than I'd want from a web app. Potentially could be solved with some client side cache but still..

Yeah something is DEFINITELY up. This is not the norm, we haven't seen this before. Fly.io free tier is not happy and I'm not sure why (we've been on it for years at this point). I'm gonna disable until I can dig deeper. Have day job stuff to attend to, this is not my ideal Friday afternoon :P

Re: Datastar: Web Framework for the Future?

#35

If you want a solid demo of what you can do with datastar. You can checkout this naive multiplayer game of life I wrote earlier in the week. Sends down 2500 divs every 200ms to all connected cliends via compressed SSE. https://example.andersmurphy.com/

Wow, I've never done multiplayer GoL. Simple yet addictively fun. LONG LIVE THE ORANGE CIVILIZATION!!

edit: damn, purple civilization got hands

Re: Datastar: Web Framework for the Future?

#36

Earlier quoted context omitted.

I think, at least as the creator, I've seen the "fight" be MPA vs SPA. IMO, both are wrong. It's about state management. MOST state lives in the backend but you still need fine grain reactivity on the frontend. On the number line between React and HTMX; Datastar is complex :)

Data may live in the backend, but it is used more in the frontend. Having it local (in memory, or even indexeddb) makes more responsive apps, especially if it's a typical CRUD app with 70/30 or more split between reads/writes.

We'll just have to disagree here. The browser is REALLY smart about caching and no amount of JS localStorage is gonna match proper E-Tags and CDNs. If it's dynamic content your point is moot anyways.

Re: Datastar: Web Framework for the Future?

#37

Earlier quoted context omitted.

a signal is not a single event but rather a stream of events at given timestamps (or, if you wish, a stream where you have an Option at each timestamp)

I googled this and got a few different answers, but not this one. Is there a particular implementation you’re referring to?

Alien, Reactively, TC39 are all about the core semantics of signal, computed, effect. Much of the rest is implementation details. https://dev.to/this-is-learning/the-evolution-of-signals-in-... is a good intro.

Re: Datastar: Web Framework for the Future?

#38
post #4

> "what is a signal?" it's another word for event

a signal is not a single event but rather a stream of events at given timestamps (or, if you wish, a stream where you have an Option at each timestamp)

I think your confusing signals with observables

Re: Datastar: Web Framework for the Future?

#39

Earlier quoted context omitted.

Is sending 10,000 divs/sec the right solution for this problem, or is this an "everything looks like a nail" solution?

This is a Wirth's Law solution - the reasoning goes: "computers are fast enough to deal with it, so why not?"

But, you can learn a lot doing dumb stuff. I learnt a lot about compression.

If you go to google chrome and throttle the site to 3G it will still run fine.

Rendering on the server like this will be faster for low end devices than rendering on the client (as the client doesn't have to run or simulate the game). It just gets raw HTML it has to render.

Effectively, the bulk of the work on the client will be done by the browser native rendering code and native compression code.

The other thing that might not be obvious. Is #brotli compression is not set to 11, it's set to 5 so similar CPU cost to gzip. But, the compression advantage comes from compressing the SSE stream. Tuning the shared window size cost memory on client and server but gives you a compression ratio of 150-250:1 (vs 30:1), at the cost of 263kb on both server on client (for context gzip has a fixed window of 32kb). This not only saves bandwidth and make the game run smoothly on 3G it also massively reduces CPU cost on both client and server. So it can run on lower end devices than a client heavy browser app.

So server driven web apps are better for low end devices. The same way you can watch YouTube on a low end phone but not play some games.

Re: Datastar: Web Framework for the Future?

#40

Datastar author here... AMA, but know that Datastar is pure yak shaving for me to do real work stuff so I have no golden calves, just approaches I've seen work at scale.

What do you think about the Hotwire stack (Stimulus, Turbo) as compared to Datastar ?

Not a fan (andersmurphy actually is better at explaining than me). However! I've been working with Micah from the Turbo.js team on idiomorph ideas. We are already multiples of v0.7.3 right now and getting faster each day. Together we can solve the core ideas even if we disagree on the top level API.
Post reply on HN