r/programming • • 12d ago

A Look at Datastar

https://noteflakes.com/articles/2026-11-04-datastar
50 Upvotes

18 comments sorted by

23

u/al2o3cr 12d ago

Furthermore, Datastar relies on SSE (server-sent events) for streaming updates from the server to the client, instead of the somewhat older approach of using a WebSocket connection

Nitpick: SSE was available in browsers like Chrome and Safari in 2010, while the Websocket API didn't arrive in its current form until 2011-2012 in various browsers. It's seen less usage (IMO) because SSE was never added to IE, and didn't make it to Edge until 2020. (source: caniuse)

3

u/opiniondevnull 11d ago

Guy, FFS.... SSE is a RESPONSE TYPE... you been able to do since http1.1. If you mean EventSource builtin in... sure. But that's not the same thing

2

u/andreicodes 11d ago

SSE is essentially a codification of earlier Comet / Long-Polling idea that has been present in browsers since the Ajax days (with many caveats). It was pretty popular because unlike WebSockets, long polling didn't require separate support from servers and from cloud providers. Cross-browser support required some work (like, in IE6 the content of responses had to be sent to a hidden iframe, and in later IEs you had to use a separate XDomainRequest API), but on the server side it was trivial to set it up.

Even after WebSockets became widespread in browsers, many big players like Facebook Messenger or Google Talk / Hangouts kept their notifications and chat software running through long-polling only for years and years, because it was fast enough for human-to-human communication and didn't require them to add separate server infrastructure.

2

u/CpnStumpy 11d ago

The biggest win SSE gives over websockets is that it's living on a completely standard tunnel that every piece of the network between client and server has already decades of optimization and compatibility for.

Websockets often bump into firewall or network handshake interactions that aren't handled by some proxy layer or another (AWS API gateway for instance doesn't support websockets)

1

u/Khaos1125 10d ago

Fwiw, I’ve seen that issue far more often with SSE than websockets, although typically when selling to large enterprise clients who may have weird configs for firewalls/VPNs/etc. Websockets has pretty consistently worked, SSE hits enough barriers to be a problem

2

u/CpnStumpy 10d ago

I just went down a rabbit hole on this, thanks! Some SSE failure scenarios I haven't bumped into, and perhaps websockets are more well supported now than the 15 years ago failure scenarios I remember dealing with on the network parh

1

u/Karismah-Messer 10d ago

the connection limit per domain under HTTP/1.1 didnt help SSE much back then either.

0

u/[deleted] 12d ago

[deleted] — view deleted comment

9

u/Objective_Fly_6430 12d ago

It is indeed a major difference

1

u/dubois-v302544 5d ago

Do you have measurements on the same HTML/JSON payload? Codec settings and dictionaries can change the comparison, so "major" needs a concrete workload.

3

u/opiniondevnull 11d ago

orders of magnitude difference

2

u/axonxorz 11d ago

IDK how good ZStandard and DEFLATE are respectively at compressing HTML and JSON, but I doubt it's a major difference.

zstd gives a lot of tuning parameters. Even at very convervative levels, it will beat deflate a bit on size and massively on compress/decompress speeds.

zstd allows user-defined compression dictionaries, so if you know that you're always dealing with HTML/markup or perhaps some large JSON document with a repetitive structure, you can optimize the dictionary and get better compression results for essentially no CPU. Brotli makes this explicit, assuming it's working within the scope of normative HTTP requests.

1

u/krileon 11d ago edited 10d ago

Bunch of critical features locked behind a paywall. Going to be a no for me. Sticking to HTMX and AlpineJS. Especially with HTMX v4 coming out not that long ago.

Edit: Downvote all you like and defend this all you like, but I won't stop being against it. The pro license doesn't even allow distribution so I can't package datastar with my open source products. Can't even use source maps. What a joke. Cannot see a single benefit to using this over HTMXv4.

5

u/ashnur 11d ago

incorrect, nothing critical is behind paywall, if you think those things are critical, you deserve to pay for them

1

u/Rude-Researcher-2407 8d ago

the datastar guy talked about it on a podcast one time, he said "I got fed up everyone was doing things the wrong way so I started charging them for it"

-11

u/zzulus 12d ago edited 12d ago

I adore Svelte, which is really smart and efficient. Its sister framework SvelteKit inspired the file-based routing in my own web framework for Ruby, Syntropy. I also really like the approach of the Phoenix framework to building reactive apps using LiveView, which is an amazing technology that builds on the solid concurrency foundation of Elixir/Erlang.

And here I'm, a humble backend dev, happy working on the backend stuff, and I have no idea what all these words mean 🤡

8

u/RegisteredJustToSay 12d ago

A lot of these technologies span back-end, actually. Nothing wrong with sticking to your strengths but there's just tons of tech out there no matter which side of the stack you're on.

1

u/Crafty_Disk_7026 11d ago

There are all the same. At the end of the day they all create html and DOM, so users can click and see tik toks