HNHacker News
TopNewBestAskShowJobs

matlin

563 karma · joined February 14, 2017

Making Triplit - the fullstack database (https://triplit.dev)
submissionscomments
matlin··on Triplit: Open-source DB that syncs data between server and browser in real-time
Yes great catch! One of the inspirations for Triplit's name is exactly from our use of a triple store under the hood. Datomic also has been a major influence in how we've designed the internals of Triplit
matlin··on Show HN: RemoteStorage – sync localStorage across devices and browsers
I think our goals are pretty similar but Triplit offers more flexible storage options (Durable Objects, IndexedDB, SQLite), deeper Typescript integration, and is probably a good deal simpler to operate--we are closer to Firebase/Firestore in that regard. ElectricSQL instead builds on the robustness of Postgres and SQLite.
matlin··on Show HN: RemoteStorage – sync localStorage across devices and browsers
Your app might not need it but if you want partial replication or relational querying in addition to offline-first syncing then check out https://github.com/aspen-cloud/triplit (disclaimer: I'm working on this)
matlin··on Show HN: RemoteStorage – sync localStorage across devices and browsers
I love the simplicity and kinda wish that was actually built into Chrome.

I know it would probably break things but if Google could automatically sync local storage and IndexedDB when I'm signed into Chrome on all my devices then a lot browser of apps wouldn't require making an account or even a server for that matter.

matlin··on Show HN: Triplit – The Full-Stack Database
We're focusing on JS environments first but this is not the first time we've heard this...
matlin··on Show HN: Triplit – The Full-Stack Database
Hey HN - Triplit is designed to make building collaborative and local-first web apps a lot simpler.

It works by running an instance of TriplitDB both in your client-side app and also on the server then efficiently syncs any queries you run on the client in real-time from the server over WebSockets. And because you have a complete database instant on the client, it works completely offline. Handling collaboration is a lot easier with Triplit because each entity you store gets split into its individual properties so conflicts that may occur when multiple users are editing concurrently are solved granularly on a per-attribute basis rather than the entire JSON document.

We're in the process of building out a Firebase-like service (in private beta currently) but in the meantime you run the entire Triplit stack locally with our CLI. Happy to answer any questions!

matlin··on Endatabas: A SQLite-inspired, SQL document database with full history
This is cool. I like that it makes it super easy to get data into the database rather than having to meddle with schemas in advance.

Looked through the documentation briefly but couldn't figured out how selecting nested properties or filtering on nested properties works?

matlin··on Accidental database programming
Yeah you can subscribe to overall changes to the data on a row by row basis but can't subscribe to an actual query. Many apps and libraries imitate reactive queries by just refetching all queries from Postgres when any data changes or just repeatedly polling the query every 10 seconds or so but this puts a lot of strain on the database. You can just subscribe to the replication stream but then you're left trying to reconstruct your queries in your application code which is extremely error prone and painful
matlin··on Accidental database programming
I'm currently writing a very similar article about "full-stack databases" which highlights the same pattern where many apps end recreating the logic of our backend and database in the frontend client code. The solution we're promoting is to choose a database that can run on both the server and in the client and then sync between them.

The reason we aren't using Sqlite for our product is because Sql is frankly not the right tool for querying data for an application. It doesn't easily map to the data-structures you want in your client code and nearly all SQL databases have no way to subscribe to changes to a query without polling the query repeatedly.

So if you like the idea of having a complete database on your client but also want deep integration with Typescript/Javascript check out what we're building at https://github.com/aspen-cloud/triplit

matlin··on You don't need a CRDT to build a collaborative experience
I think the most important part of designing collaborative software, which this touches on a bit, is having a the right granularity and scope of a given change.

Last-writer-wins is only bad when the granularity of what you're editing is too big. E.g. if you're an editor like Figma and each element is a row in a database, a single row is too big. Instead you want attribute level granularity so two users can change the independent properties (like one color and the other size) without bulldozing each other.

The other key thing (that's also a common mistake) is to only consider realtime collaboration. In practice, there's always some delay (maybe just milliseconds but could be be hours or days) in how events propagate so solutions like locking don't work.

The reality is that any client-server system that needs to be highly interactive and robust to unreliable network conditions is undeniably a distributed system and therefore warrants using distributed system solutions like vector clocks, Lamport timestamps, CRDTs, etc.

Last thing is that I think many people only think of operation-based CRDTs when they think about CRDTs. You can (and we have at my company) created a fairly traditional feeling database that relies on a state-based CRDT solution that doesn't need to maintain a log of every operation that has every happened.

So yes, you might not need to reach for a fancy library like Yjs or Automerge, but it's worth understanding how these things thinks basically work because many of them are extremely simple and easy to grok - the complicated parts of Yjs and Automerge are the sophisticated data-structures and algorithms that are pretty much only needed for large document text editing.

matlin··on Reflect – Multiplayer web app framework with game-style synchronization
Can you share how y'all made it fast? Obviously it can be made fast because multiplayer online games are living proof but I'm curious what it takes to get there or what's missing in my mental model.
matlin··on Reflect – Multiplayer web app framework with game-style synchronization
While I do love the simplicity of this approach on the surface. Some of the complexity gets brushed under the rug.

Firstly is rebasing these operations in this style of system takes a bigger hit on performance than I expected in my experience. Sure, managing counters and doing integer math can consistently run at 120FPS but more complex operations can really bog down the system when a lot of users are interacting with it once.

The second challenge is that when operations fail (e.g. for authorization) undoing that operation isn't always straightforward. You either pop the operation and replay ops from a earlier snapshot (which necessitates storing all ops in order), writing an inverse operation manually, or having the server send the entire state back to rebase your unconfirmed ops on which can also end being expensive.

In general, the challenges of this approach are true for all operation-based CRDTs too. State-based approaches are a good deal simpler just tend to over-send data over the network.

matlin··on Modeling CRDTs in Alloy – the importance of idempotence
For those like me who didn't know what Alloy is, it looks like it's a general purpose constraint solver for testing correctness in range of different algorithms.

https://alloytools.org/

matlin··on An interactive intro to CRDTs
Not a dumb question at all! We're aware of cr-sqlite and I've talked to the author, Matt, a few times. Short answer: SQLite has serious shortcomings when it comes to reactivity and we think we can be as fast as SQLite for the application-type queries we aim to support. The long answer would be about supporting all of features we don't need in SQLite and all of the quirks that come with it like having null as a primary key[1].

We also recently came up with a relational-style querying system without joins! https://twitter.com/triplit_dev/status/1707509447789043760

[1] https://twitter.com/tantaman/status/1702677401291903116

matlin··on An interactive intro to CRDTs
Evan Wallace (co-founder of Figma) has one of the best visualizations of CRDTs in action https://madebyevan.com/algos/crdt-fractional-indexing/

In practice, most apps will only need Last-Writer-Wins registers and not the more complicated sequence CRDT's that you find in Y.js and Automerge.

We've built a auto-syncing database that uses CRDTs under the hood but never exposes them through the API. So if you want all of the benefits of CRDTs e.g. offline-first user experience, checkout our project, Triplit!

matlin··on Notion experiencing issues (over 6 hours)
This is the motivating behavior behind triplit.dev (disclaimer: I'm a developer on it). Every productivity app should be able to keep chugging along whether the server is online or not. Makes server outages like this WAY cheaper.
matlin··on I'm all-in on server-side SQLite (2022)
If you need multiple writers and can handle eventual correctness, you should really be using cr-sqlite[1]. It'll allow you to have any number of workers/clients that can write locally within the same process (so no network overhead) but still guarantee converge to the same state.

[1] https://github.com/vlcn-io/cr-sqlite

matlin··on Agentscript: Agent Based Modeling in the Browser
I took a a couple classes in college that were taught in NetLogo. While it isn't the most practical language (except for visual simulations), I think it's incredibly valuable to learn to think in terms of isolated agents. It brings together OOP and functional programming and is a good foundation to learn multi-threading or light-weight processes like in Erlang/Elixir.
matlin··on Some notes on local-first development
This is an awesome resource! Glad Triplit made the list of hosted services (we're also open-source)

One common misconception with local-first, is that it's essentially local-only. But I believe the best experience is where the server and client are equally capable and only a partial set of data is stored on the client. The server still maintains authority but the client is always snappy when updated data or changing queries/views. We basically call this a full-stack database and we're building that at [Triplit](www.triplit.dev).

matlin··on TikTok Shop
That's pretty insane that TikTok will also do fulfillment! That has to be a major differentiating feature from all of the other social media companies right? I would be very surprised if Meta or Google did anything close to that when it comes to shopping.

Not hard to imagine a new generation of shops that are exclusively on TikTok and don't even use Shopify or some other e-commerce stack.

matlin··on DBSP: Automatic Incremental View Maintenance for Rich Query Languages [pdf]
The idea of representing a view over a stream with a type of circuit diagram is really neat and seems like the big unlock here.

Makes me wonder if you could create a toy implementation in a reactive stream library like RxJS but one that is glitch-free[1]. I'll have to give this a try in our Typescript database we're developing that has basic incremental view maintenance currently.

[1] https://en.wikipedia.org/wiki/Reactive_programming#Glitches

matlin··on Cola: A text CRDT for real-time collaborative editing
Any comparisons to Automerge or Y.js/Yrs regarding performance or features?
matlin··on Val Town Runtime v3 – My mistakes were easy, the solutions simple
Refreshing to see how much care is being taking to mantain compatibility with the greater JS ecosystem. No easy task when there's a dozen runtimes these days (Node, Deno, Bun, Hermes, etc).

Kinda surprising that fetchJSON (or some equivalent) hasn't made it into any standard libraries yet

matlin··on Cap'n Proto 1.0
The lead dev of Cloudflare workers is the creator of Cap'n Proto so that likely made it an easy choice
matlin··on EdgeNode: Deploy Serverless Containers on Edge
Does EdgeNode doing anything differently from Fly.io?
matlin··on Real-time messaging
Kind of funny timing because I've noticed my messages in Slack have been quite a bit more delayed than usual for the last few months, especially when moving between devices. Maybe they need more "channel servers"
matlin··on Show HN: Front end-Only-Authorization – A new web standard
Seems more of a generic authorization proxy rather than anything frontend related. Useful but "front-end only" doesn't seem to to accurate
matlin··on CRDT-richtext: Rust implementation of Peritext and Fugue
Cool, I'll check out your repos. Supabase also has Postgres CRDT (https://github.com/supabase/pg_crdt).

But, in general, I think searching in and across documents and database storage is going to a thorny problem even with existing, hyper-optimized CRDT algorithms. For example, if you just store your Yjs document as a binary blob in a Postgres column, Postgres becomes the bottleneck and all the fancy range-tree or b-tree optimizations are no longer that helpful on the server. Plus, it'd be great to have an document edit just be a tiny insert into the database that can be streamed to other clients rather than a big row update.

This may because the focus of CRDTs seems to be rooted in a fully decentralized, P2P system but many developers want collaborative text editing in a more traditional client-server model.

matlin··on CRDT-richtext: Rust implementation of Peritext and Fugue
I'm happy to see even further performance improvements towards rich-text CRDTs but at this point, I think the barrier to adoption isn't speed or compactness but instead integration with existing backends and databases.

I have a hunch that we're reinventing the wheel by creating new B-Tree implementations in Rust when we could be figuring out how to make an existing database do the hard work of storing and retrieving characters in the correct order. I know Martin Kleppmann has looked at Datalog being a potential solution to this problem but until we have a good full-stack solution to collaborative text editing, I don't think we'll see major adoption of these CRDT solutions.

matlin··on Bun 0.6
It bundles an entire JS engine with it. I think JSC in Bun's case. V8 for Deno and Node.
← PreviousPage 3 of 6Next →