News for hackers. Stuff that matters.
Re:Local-First Web Development by hem777 on Sunday February 19, 2023 @11:27AM (#34858970)
How about having the state 100% on server AND on client? No dragons, no problems.
Re:Local-First Web Development by treis on Sunday February 19, 2023 @11:47AM (#34859193)
Keeping them in sync is the dragon
Re:Local-First Web Development by mlajtos on Sunday February 19, 2023 @11:58AM (#34859340)
CRDT is the dragon slayer
Re:Local-First Web Development by iamwil on Sunday February 19, 2023 @12:17PM (#34859573)
It's the sword that we needed! But it doesn't take us all the way. There are semantic conflicts that are difficult for CRDTs to solve alone.
Re:Local-First Web Development by hem777 on Monday February 20, 2023 @12:26AM (#34865206)
What are the semantic conflicts you mean here?

As far as I can tell, CRDTs are the correct solution for syncing state between parties.

Re:Local-First Web Development by towawy on Monday February 20, 2023 @03:20AM (#34866166)
Merge conflicts that must be resolved by the user (i.e. when there is no logical way to determine the priority of two offline changes) are still an application specific problem, even with CRDTs. You can build structures that allow storing conflict resolutions in CRDTs, but getting them right is still like half the problem to solve.
Re:Local-First Web Development by mlajtos on Monday February 20, 2023 @09:23AM (#34868328)
Yes, sometimes it is hard to come up with the merge strategy that preserves user intent. I think the big one is rich text, where Peritext[0] looks like a good direction.

[0]: https://www.inkandswitch.com/peritext/

Re:Local-First Web Development by hem777 on Wednesday February 22, 2023 @12:40PM (#34899439)
I have lack of imagination to think what kind of conflicts those would be, would you have examples?

In my experience there’s always a logical way to solve conflicts. And CRDTs can have any kind of conflict resolution algorithm, so it’s customizable per application. “Storing conflict resolutions”, eg. “a merge operation”, is not needed and unnecessarily complicates any CRDT.

Re:Local-First Web Development by hem777 on Wednesday February 22, 2023 @12:52PM (#34899661)
This is the correct answer :)
Re:Local-First Web Development by rs999gti on Monday February 20, 2023 @09:54AM (#34868612)
How do you prevent sync issues?

One local DB/store for each app. Who is the correct sync?

Or is it first in first out?

Re:Local-First Web Development by hem777 on Wednesday February 22, 2023 @12:47PM (#34899567)
CRDTs is how sync issues become non-issues. The “correct sync” is deterministically determined by the CRDT conflict resolution algorithm. There can be multiple DBs/stores per app or per user or per whatever makes sense. One big global DB/store broken down to millions of DBs/stores.
Re:Local-First Web Development by ohgodplsno on Sunday February 19, 2023 @12:02PM (#34859406)
Then you get to deal with conflict resolution, which is a rare dragon that is kind of confusing and sometimes has to ask the user which state they'd like to keep.
Re:Local-First Web Development by Drew_ on Sunday February 19, 2023 @09:45PM (#34864385)
Not if you assume the server is always right. Which is suitable for the majority of cases.
Re:Local-First Web Development by hem777 on Wednesday February 22, 2023 @12:50PM (#34899630)
Another possibility is to assume the user is the authority and is always right. For example, if I post a tweet to my feed, I’m (or should be) the authority and always right.