jb55's avatar
jb55 _@jb55.com 8 months ago
I'm not sure if @fiatjaf intended this when designing the protocol, but it affords use cases that do not depend on a remote api. and that is really useful. the protocol dictates a uniform query interface that doesn't necessarily depend on location. so this enables local-first apps with optional remote replicas. not *needing* an api is huge. the query language is the universal api. this means a local app would work exactly the same as one with data stored on a remote relay. you *do* have blocking write confirmations, I added it to the protocol in the form of command results (OK). you just don't have transactions, but that can be implemented at a local layer before replicating. I imagine building a distributed transaction model would be complicated, dbs like tigerbeetle and foundationdb are very complicated. the only other project I can think of tackling this in an interesting way is via a deterministic logic language for building data models in a metaverse context, but that is also complicated. nostr avoids this transaction complexity by an append-only graph style way of coding apps... if you ignore replaceable events, which I very much try to do at all costs, except where I can't at the moment (profiles, contact lists)

Replies (2)

Nuh's avatar
Nuh 8 months ago
Fiatjaf is definitely a strong believer in RPC as superior to HTTP based API. However, I think this is a week point, you can send HTTP queries over Bluetooth, HTTP headers are not inherently inferior to JSON, i argue it is better, if only because it allows for using curl and all the infrastructure of talking to servers. I will however agree that a query language that is simple enough, and thanks to Fiatjaf discipline; resistant to creep and complexity is a great feature... but this is not special to Nostr either, nor does it get embedded by a canonical source of truth or a key value stor api. You can name your keys in ways that make them effectively lookup indexes, which already covers many of what Nostr queries do. The append only way is also entirely possible in a system like Peergos, and if you ONLY create new files. Then the CAS will never fail, but then you have extra features that Nostr doesn't have, like being able to see exactly what is the current state, and GC older leaves (which is what LMDB does as well) and everything we take for granted when we have a reliable database. I am not supporting decentralised databases to the contrary, I am supporting a single writer (home server) so that we don't have to fuck around with decentralised transactional databases.. too hard. But the price of that, is a server, usually in the cloud. My hope is that smart builders stop perceiving that as a bad thing, as long as the migration between home servers is smooth and permissionless. Either way, I trust that people would converge into that eventually, and we would have something like Proton Drive (but open and self hostable) as the base layer of free web development, especially with decentralised PKI to make migration better than what it is in say Mastodon. I hope I did enough work to enable that.
There’s also the question of do you need transactions. There is transactions for consistency, and there’s transactions to ensure correctness of the system state (like indexes) Many Nostr use cases actually do not need strict consistency. There is only some level of correctness required. CRDTs and conflict resolution fixes this. A notes app for example can be represented as a set of diffs on top of each other, and two updates to the same note can be merged. This is also why Dynamo and eventually consistent databases exist. You could also have slightly smarter relays that can do slightly smarter queries if you want.