News for hackers. Stuff that matters.
Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @06:05PM (#41745966)
Wonderful work, but this doesn’t look like local first software to me. It looks like server first software with live updates and caching.

Don’t get me wrong, that’s super cool - but if you’re going to claim it’s local first software, I want to see the principles of local first software at play. And I don’t think Zero delivers that - at least as I understand it from its website.

Like, “the network is optional” and “the long now” and “you (the user) retains ultimate control”. It just looks like an excellent server sync system with client side caching. What if the data I need isn’t in the cache? What happens when I edit things offline then come online later? What happens if the company shuts down and the server gets turned off permanently? Will the app still work?

Local first software can handle these cases too.

[1] https://www.inkandswitch.com/local-first/

Re:Show HN: One – A new React framework unifying web, native... by nwienert on Friday October 04, 2024 @08:21PM (#41746740)
I think this is fair, as they haven't committed to offline - though they've said they want to do it, they just want to wait to do it right. That said, they do work fully client-side, so I wouldn't say it's server-first, it's more of a hybrid. I will try and clear this up in our wording.

Final note on the user-stuff: that's always up to the person writing the app anyway. You could make a "download the IndexedDB" button with a couple lines of code, but it's more than that, it's really a whole bunch of decisions you have to make as an app-developer to commit to it. And tbh I think the general understanding of local-first has settled on client-side + optimistic + offline - for the better.

Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @08:53PM (#41746870)
> I wouldn't say it's server-first because the mutations are happening locally first and every feature works fully client-side.

That's not even close to what "local first software" means.

Can apps work without the server? Like, if the server goes down, will the app still work?

Can I collaboratively edit my data without the origin server? (Or at all?) Normally replication built on raw postgres queries relies on atomic row level locks on the server, while processing transactions. What happens if two people edit the same data at the same time?

Does it support end-to-end encryption, so my data isn't readable by the server at all?

Can I back up the app & my data together, and open it back up in 5 years and have the app still work?

All this stuff is talked about in the local first paper. Putting a sync engine in front of postgres (as described by the zerosync website) doesn't do any of this stuff. (Or maybe some of it? Its hard to tell without more information, and I can't find a link to the source code.)

It reminds me when Zoom advertised E2E encryption on zoom's website because the CTO clearly didn't know what "end to end encryption" actually means. It looks like an excellent product - so why exaggerate its capabilities?

"Local first" doesn't mean "edits are applied speculatively in the client before they hit the server". It also doesn't mean "caching part of the centralized postgres database in the client".

Go read the paper. The details matter. https://www.inkandswitch.com/local-first/

Re:Show HN: One – A new React framework unifying web, native... by nwienert on Friday October 04, 2024 @11:30PM (#41747508)
Joseph, I think you’re misunderstanding Zero. Its entire DB engine runs client side. You can run Zero offline and mutate away all day and use your software as you please. You can download your data and keep it (if you design your app that way). All of those criteria are met.

It does work without a server. But as of today it won’t handle going back online properly and syncing if you are offline for a while. So most people will use it online only, as a sync engine and client database.

I read the local first paper the day it came out, I’m a big fan of Ink and Switch and have read much of their work.

I’ll leave it at that and will look at avoiding the language - though you’re actually the only person who’s has this complaint.

Re:Show HN: One – A new React framework unifying web, native... by aboodman on Friday October 04, 2024 @09:19PM (#41747003)
[Moved up thread]
Re:Show HN: One – A new React framework unifying web, native... by aboodman on Friday October 04, 2024 @10:14PM (#41747234)
To answer your specific questions:

> What if the data I need isn’t in the cache?

The developer can arrange for all the data to be in the cache if the want that part of the app to be fully offline capable.

> What happens when I edit things offline then come online later?

Zero won't support offline mutation at launch, but there's nothing preventing it from working. It is built on [Replicache](https://replicache.dev) which does support offline mutation.

I think almost no software that claims to be local-first actually supports robust offline editing and merging. The only people I've seen really go for this is the I&S folks with their branching stuff and that was just an experiment.

I'm excited to do this right, but most of our users care more about the ux and dx improvements while online, so we'll do it later.

> What happens if the company shuts down and the server gets turned off permanently? Will the app still work?

Developers can self-host Zero. In advance of any standards for sync, this is about the best you're going to get with any local-first software today, except maybe stuff that syncs to Dropbox (which is cool!).

> Can apps work without the server? Like, if the server goes down, will the app still work?

Yes. Read-only at alpha, and later read-write.

> Can I collaboratively edit my data without the origin server? (Or at all?) Normally replication built on raw postgres queries relies on atomic row level locks on the server, while processing transactions. What happens if two people edit the same data at the same time?

Yes. Zero uses server reconciliation, like our previous products Replicache and Reflect. You can read more here:

https://rocicorp.dev/blog/ready-player-two

(how could you even do realtime collaboration with postgres locks? that doesn't really make sense)

> Does it support end-to-end encryption, so my data isn't readable by the server at all?

Sure. That's up to the developer in how they design their database schema, but of course it's possible.

> Can I back up the app & my data together, and open it back up in 5 years and have the app still work?

I mean I guess so? If you had it in an electron app you just snapshot the data directory? An app developer could arrange for this to happen if it was important to them.

Does this all count as local-first? I think it's about as local-first as most other software claiming the title. But again, I kind of prefer to focus on what our product does and for that reason I try to avoid claiming we're local-first.

Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @11:00PM (#41747421)
Thanks - very interesting stuff!

> Yes. Zero uses server reconciliation, like our previous products Replicache and Reflect. You can read more here: https://rocicorp.dev/blog/ready-player-two

Oh I hadn't seen that before, and I love that. It looks like an extension of database transactions / MVCC into the client.

Its interesting thinking about what situations this will & won't work in. I imagine it'd work for most of the mutations made in most applications, like editing rows in a database. And in your example, inserting at the end of a list would work.

But what about inserting in the middle of a list (or, typing in a text document)? Naively, it wouldn't work because "insert at position X" changes its meaning wrt. concurrent edits. But you could make OT work if you provided a way to change the arguments themselves if concurrent changes were detected. (Thats essentially all OT is. When concurrent changes happen, run the transform function. op = transform(op, other_op)).

Interestingly, I think you could use a text CRDT (like yjs) with your architecture. You would need to run the crdt's prepare function in the client first, to convert the edit into the CRDT's format (eg for Yjs, that looks like Insert('a', left_id: XX, right_id: YY). Then if you passed that object into the transaction closure, you could run the CRDT on the server and it'd all work out.

Its not quite as obvious and straightforward as your examples. But still, very cool that its extensible like that.

Re:Show HN: One – A new React framework unifying web, native... by hosh on Friday October 04, 2024 @09:07PM (#41746945)
That is a disappointing interpretation of “local-first”, and would not suit the kind of applications I want to write.

On the other hand, this is still tethered to the server, so likely more commercially viable than a true local-first design.

Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @09:48PM (#41747118)
> That is a disappointing interpretation of “local-first”, and would not suit the kind of applications I want to write.

I don’t think anyone wants or expects all software to be local first.

What would it even mean to "locally first" turn the lights in my house on and off, check the weather, or play a multiplayer-only video game?

Local first makes a lot of sense for some use cases - like personal / creative work (eg Apple Notes). But not for others.

Re:Show HN: One – A new React framework unifying web, native... by hosh on Saturday October 05, 2024 @04:44AM (#41748550)
- turn on lights — there are smart light bulbs that phone home to the cloud. Along with smart assistance, home automation, etc. those are exactly the things that should be local-first, or at least, the server software should be onsite (such as Home Assistant — edge computing). We already have examples of what happens when companies shut down the servers those automations depend upon. To go even fuether, each device that is truly local-first enables the kind of cooperative automation conceived of in Promise Theory.

- checking the weather — although predictions are easier to come by from NOAA’s weather models, areas can have microclimates both natural and man-made that are not so easily predicted through atmospheric modelling. Permaculture design includes scaling microclimates in very small areas (on the order of specific plants) to tweak what can grow there. Local-first makes sense if you want to instrument those microclimates. Better yet, there are ways to read the clouds and conditions to get decent predictions for weather conditions for your immediate area.

- local-first multiplayer video game - what an intriguing idea! The closest I can think of is that multi-user virtual reality spaces that was built on a modern version of Smalltalk. It isn’t local first, but it supports multiple, independent servers that mesh together. There are probably also ways to do this with turn based games, such as chess or go.

Do you have any other examples? The ones you brought up were a good exercise to see how far one can take local-first design.

Re:Show HN: One – A new React framework unifying web, native... by swiftcoder on Saturday October 05, 2024 @09:38AM (#41749745)
> What would it even mean to "locally first" turn the lights in my house on and off?

It would mean that even when the vendor decides to disconnect the cloud server, the app still knows how to find the lights over the local WIFI and turn them on-and-off. This is one of the poster-child use cases for "local first".

> check the weather?

There's less to work with here, because we generally treat weather as a read-only use case. But it isn't! There are weather apps today that let you connect to your own local weather station, and/or fetch results from other tiny weather stations in your region. All of which could be handled in a "local first" manner (modulo some reasonable way to discover nearby weather stations).

> or play a multiplayer-only video game?

Chess, scrabble, or really any asynchronous turn-based game can be handled via local edit for your move, and then sync to your peer (optionally through a server for easier coordination).

Re:Show HN: One – A new React framework unifying web, native... by josephg on Saturday October 05, 2024 @11:00PM (#41754416)
> It would mean that even when the vendor decides to disconnect the cloud server, the app still knows how to find the lights over the local WIFI and turn them on-and-off. This is one of the poster-child use cases for "local first".

I agree with this, but my point is “what should the app do when you’re offline” - as in, your phone is on aeroplane mode. “Local” as in, local to your device. Not your wifi.

What does it mean to turn the lights on and off in that situation?

In my opinion, nothing, it shouldn’t work. And if that’s true, the light is essentially a server, the app / phone is a client. Nothing has changed except making the routing more efficient.

Re:Show HN: One – A new React framework unifying web, native... by swiftcoder on Monday October 07, 2024 @04:05AM (#41763758)
Sure, that's just the nature of interacting with a remote object of any type. But I don't think that invalidates wanting the app to be designed in a "local first" manner with respect to whatever happens to the cloud backend.
Re:Show HN: One – A new React framework unifying web, native... by josephg on Tuesday October 08, 2024 @03:41AM (#41774674)
Right. A remote object. But the point of local first software is the objects are local.

If I edit a note using Apple Notes, I’m not editing a remote object. I’m editing something local - authoritatively local - to my device. The server doesn’t know more than my phone does, and the server doesn’t get to tell my phone that I don’t have permission to edit my own, local stuff.

That’s different from interacting with a remote object as a client. Hence, I don’t see turning a remotely controllable light on and off to be local first software because way more like interacting with a server than it is like Apple notes. The server just happens to be harder to route packets to sometimes.

Re:Show HN: One – A new React framework unifying web, native... by swiftcoder on Thursday October 10, 2024 @03:36AM (#41796501)
By that definition, pretty much the only apps that qualify for local first are document stores. I'm not convinced that it is useful to narrow the definition that far (nor that most of the local first advocates would agree with such a narrowing).

We're basically talking about 1 bit of state that the light is authoritative about (on/off), versus all the other state that your copy of the app can be authoritative about (configuration, schedules, etc).

Re:Show HN: One – A new React framework unifying web, native... by aboodman on Friday October 04, 2024 @09:32PM (#41747045)
Hi Joseph,

There is a lot of debate about this in the community. People like pvh, adam wiggins, and johannes have all said they consider Replicache and Zero part of the local-first movement [1] and that they would be sad if we and other things like us weren't in it. I was even invited to speak at local-first conf, where we announced Zero last May. [2]

I think in practice delivering on the local-first ideals is ultimately up to the app developer not the library. Like in practice every yjs app talks to its server over some bespoke protocol and is loaded over a URL. If that server goes away your yjs app is a brick. No less a brick than if your zero server goes away.

Similarly although everyone likes to claim Linear as a local-first app, if the Linear server goes away your Linear app is a brick. Yeah you can export the data from IDB or whatever but you could do the same for Zero or any of these systems.

That all said, for our part, we have recently tried to avoid claiming Zero and Replicache as local-first on our own sites to avoid this controversy [3].

I think we're building something really valuable that a lot of people are excited about. And I think we're making the right tradeoffs for the majority of software that most people use every day. So I don't really care too much if it qualifies as local-first (except insofar as I like hanging out with the local-first folks and would be sad to not get invited to the parties).

I forgot to mention this to Nate when he showed me these mocks for One because honestly almost everyone else (not us) refers to Replicache and Zero as local-first and it's easy to forget. I'll leave it to him to decide what to do with his own product, but it seems easy enough to me to soften the language.

[1] https://youtu.be/cgTIsTWoNkM?si=6bYAAunqd5kdl-UL&t=2692

[2] https://www.youtube.com/watch?v=rqOUgqsWvbw

[3] https://zerosync.dev/, https://replicache.dev/

Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @10:18PM (#41747245)
> I think we're building something really valuable that a lot of people are excited about. And I think we're making the right tradeoffs for the majority of software that most people use every day.

I agree! I wanted live server sync like this for years. And I built ShareDB years ago along those lines, many years before the term “local first” came into being.

But I see a pretty big difference between “server based app with sync” and “local first software”, party invitations aside. I wish we made a term for server based sync - I think it’s marvellous, and it’s important for all sorts of use cases. I think it’s ridiculous modern databases don’t have live queries built in as a standard part of sql. You’re doing great work here.

But all that said, I personally actively avoid calling sharedb local first because I don’t think it is. One big difference is authentication - who has permission to edit the database? And when? With sharedb (and I assume zero), it’s possible to add logic on the server to reject edits. It’s not possible to do this in the same way when clients can write to Yjs or automerge, connect to one another directly and broadcast their changes without the server in the loop.

That’s a pretty big difference - at least to me. I can’t speak for pvh, since I don’t get invited to those parties. But I want language to differentiate those two kinds of software. I’ve been writing software that straddles that line for over a decade, and that difference of how authoritative the root server is really important. It really changes a lot of things about how we build software.

I think the situation is like if we didn’t have a good term for client-server encryption so everyone just calls their software E2E encrypted even when it’s just using tls and encrypting data in transit.

I don’t think you should stop going to local first events. But I don’t think being invited to super cool parties tells us anything about your code. That makes you, personally, a member of a community. But the local first software question is, as I see it, a technical distinction. Not a social one.

The zerosync website says this:

> But where Zero really shines is “local-first” style applications like Linear and Superhuman.

Personally, I find that a pretty confusing claim. “Seamless online / offline support”? Sure. Rad as f? Absolutely. Local first? Eeehhh. It looks like a modern sharedb with a Postgres backend, better caching, maybe cleaner client side api and no collaborative editing. Definitely cool, but very, very different how local first software is described in the paper. That or I should start claiming sharedb is local first too, and muddy the waters forever. Gmail offline mode? Local first everyone. You're welcome!

As for websites that support offline data but can’t be loaded without a server, why not? App manifests can solve a lot of that. (Though nobody ever tries actually opening websites when they’re offline, so maybe there’s no point setting it up).

Personally, I’ve never heard of Linear. And I’ve never heard “everyone say” it’s local first. But if it’s a brick without the server, sorry, but I think everyone is wrong.

Re:Show HN: One – A new React framework unifying web, native... by aboodman on Friday October 04, 2024 @10:26PM (#41747284)
> The zerosync website says this:

>> But where Zero really shines is “local-first” style applications like Linear and Superhuman.

It is a difficult thing to communicate since the vast majority of people interested in Zero are coming looking for "local-first". And for better or worse what they have in mind is Linear (it's a very popular and widely respected bug tracker that calls itself local-first) not Apple Notes.

https://www.youtube.com/watch?v=XTMyOtvBJ_g

I'll think about how to reword.

I'm officially (waves hands in proclamation) inviting you to the next local-first conf. It's crazy fun. Tons of smart people working on all things sync.

https://www.localfirstconf.com/

Re:Show HN: One – A new React framework unifying web, native... by josephg on Friday October 04, 2024 @10:46PM (#41747359)
Hah I'll watch the video when I have a chance. Thanks for the invite - I'll have to wait and see when the time & place are announced. Maybe I'll see you there!
Re:Show HN: One – A new React framework unifying web, native... by Aeolun on Saturday October 05, 2024 @04:58AM (#41748597)
I don’t get it. Why would you call something that needs a server to work local-first :?

My app that stores its state on my local disk with optional sync to a server is local-first. If the server goes away, the app continues working flawlessly, you just won’t be able to sync any more (unless you host your own server).

I find it hard to imagine people think of Linear when they hear local first.

Re:Show HN: One – A new React framework unifying web, native... by aboodman on Tuesday October 08, 2024 @04:48PM (#41781679)
Re:Show HN: One – A new React framework unifying web, native... by andrewingram on Saturday October 05, 2024 @06:02AM (#41748788)
I think there are two valid interpretations of the words “local-first”.

1) The outcome of all interactions can be seen locally first, but are sent to a server too. Optimistic updates on steroids, largely done to make software seem faster. Linear is the notable example.

2) The app is built so that it’s fully functional and useful without any kind of internet connectivity. But if network _is_ available, there are some augmented capabilities. Think note-taking apps like the one built into MacOS and iOS, or Bear

Re:Show HN: One – A new React framework unifying web, native... by josephg on Saturday October 05, 2024 @07:44AM (#41749224)
Right. And I think only (2) should count as local first software. And only (2) fits the definition provided by the local first software paper.

Option (1) is a legitimately useful way to build software. I wish more apps considered offline support. But I don't think "it works offline" is enough to make something count as local first software. For example, I don't consider Dropbox to be a "local first" tool.

I'm worried the "local first" term will be watered down by projects like this. That distinction matters. At least to me.

Re:Show HN: One – A new React framework unifying web, native... by BodyCulture on Saturday October 05, 2024 @03:20PM (#41752243)
The crypto coin world is based on an Orwellian abuse of words / meanings.
Re:Show HN: One – A new React framework unifying web, native... by _shibru_ on Monday October 14, 2024 @01:07AM (#41834373)
Exactly this, "local-first" here mostly is a marketing term rather than a technical one.

I'll tell you a funny(real) story. where i live there is a popular valley, well let's call it X-Valley. the name is very popular and gets a lot of tourism to the valley, so much so that all the surrounding valleys now advertise them as X-Valleys on the internet. and they get a lot of (re: majority of) their tourism business from doing that.

Second is the people's understanding of the term "local-first", I doubt many truly understand the real one from ink&switch. what a good chunk of them are really looking for is offline-first or even optimistic-ui based sync system.