Live data from Hacker News

LiveView Is Best with Svelte

blog.sequin.io

121–130 of 158 posts

Re: LiveView Is Best with Svelte

#121
post #84
post #5

So instead of managing state on the client, you manage state on the client and the server? That doesn't seem like an improvement, even if it saves you from having to build yet another API.

Yeah that is the crux of most modern three-tiered architectures (client server database) these days. We're working on simplifying this with a new concept: a full-stack database. If you run an identical query engine on client and server and then sync data between them, a client can just write a normal query on the client and you get an optimistic response instantly from a local cache and then later a response from the…

That sounds a lot like CouchDB and PouchDB. I haven't used the latter, but CouchDB provides a standard REST API (with authentication) out of the box. You'll probably need to add a custom API for more complex stuff, integrating with other services, etc. But all the boring CRUD stuff is already built into the database.

But more stuff like this is always welcome!

Re: LiveView Is Best with Svelte

#122
post #120

Earlier quoted context omitted.

You are not convinced because you don't know the details. But I am not paid to advocate or to even try to convince. You've been informed now -- from here on it's on you as to whether to remain biased or to expand your horizons.

I've written elixir apps, also read Armstrong's thesis, etc etc. Beam is undoubtedly an excellent piece of engineering. I don't want to engage more than that, as the horizons comment seems bizarre in the context of the thread

No need to get defensive. Your comment came across as curmudgeon-y and biased, I called you out for it, you could have agreed to disagree which I would respect. But no, you had to go out of your way to try and strike.

Well, OK. But HN is not the place for that and I refuse to engage further.

Re: LiveView Is Best with Svelte

#123
post #36

> There is a (literal) speed of light limitation with this approach: your server can only be so close to your users. The next step is to compile your server to WebAssembly and ship it to your clients. You can then use it to optimistically render responses while waiting for the real server to return. Sounds a little crazy, but we've actually pulled it off for a project, and its magic.

That sounds a lot like the "client side prediction" that modern multiplayer games do.

Re: LiveView Is Best with Svelte

#124

This is great. LiveView is truly amazing and greatly speeds up development, but as the post describes, there are a couple of rough edges. They're all solvable, but sometimes there aren't clear or well-established patterns for how, so it can feel a bit ad hoc. While I'm not currently using Svelte for this kind of thing, I'm really glad to see people formalizing some of the issues + solutions.

My main complaint with LiveView is communication between components in a tree (like callbacks and sending data back). It’s still janky at a core syntax level between send, send update, etc. I feel this is something only the core team can fix because it probably requires some kind of use of macros etc.

Re: LiveView Is Best with Svelte

#126
post #113

A pattern sometimes used in multiplayer video games is there's a bunch of code that is by default run on both the client and the server. The client code runs as a prediction of the server state. When the server state is received it slams the client state. For games "prediction" is an apt description of this, because the client can make a good guess as to the result of their input, but can't know for sure since they d…

As a player of a game (Overwatch) that simulates ragdoll physics locally and non-deterministic, I wish they did it correctly. What ends up happening is someone dies and their body flies off or gets stuck in a hilarious pose... and no one else saw it, nor can you rewatch it in the replays as every client renders it differently. Unless you catch it with a live recording then it's lost forever. With a sometimes goofy ga…

In Counter Strike I've seen it be an actual issue too where a player's view is blocked by a body and their teammates don't have the same issue while spectating them.

Re: LiveView Is Best with Svelte

#128

Have you guys considered htmx before going that way? If you can share pro/cons I'd love to hear.

Author here. We did not. We briefly tried Alpine, which I think is comparable?

I think Alpine is cool, but it didn't really stick with the team. I think that's because we were still writing our components in LiveView and sprinkling in Alpine. A big unlock with LiveSvelte was getting to move so much into `.svelte` files, but not converting the whole thing to a SPA. Working in a `.svelte` file gives you a lot of niceties that an Alpine-decorated LiveView component won't (prettier, intellisense, etc).

This approach could totally work with other paradigms, like Alpine and HTMX. I think the key is using LiveView as a backend-for-frontend, so writing all your components in `.htmx` files or whatever.

Re: LiveView Is Best with Svelte

#130
post #42

Earlier quoted context omitted.

You can use asdf to install erlang/BEAM/OTP and elixir, takes a few minutes if you have some previous experience with the tool. Either way it'll probably take about two hours to have your first rudimentary Phoenix chat application loaded in a browser if you follow some guides and tinker around a bit.

I would strongly recommend using mise instead of asdf. It's a drop in replacement that is just flat out better for most people.

curious, what makes it better? asdf has always just worked for me, but this is the first time i’ve heard of mise, so i’m wondering what i’m potentially missing out on
Post reply on HN