HNHacker News
TopNewBestAskShowJobs

samwillis

30,161 karma · joined March 17, 2008

Multidisciplinary Developer, Designer and Engineer. I invent products both online and offline.

Working on sync engines, PGlite, and Tanstack DB at Neon/Databricks. Previously co-founder ElectricSQL (acquired by Databricks).

sam dot willis at gmail dot com

samwillis.co.uk

Twitter: @samwillis

submissionscomments
samwillis··on OpenAI: Scaling PostgreSQL to the Next Level
The message of the talk was very much that you can scale to massive throughput without having to shard and having only a single master.

Of course they considered it, but the tradeoffs didn't match what they wanted to do - plus they found you could scale to this level without sharding.

samwillis··on OpenAI: Scaling PostgreSQL to the Next Level
I was at PGConf last week, and this was one of the most packed talks - a great insight into using Postgres, where most of the conference was fairly inward facing, with talks around the development of Postgres itself (pgconf.dev is very much that one, out of all the others each year).

What you have to remember is that for many teams, when their product takes off, they are not equipped with the deep internal knowledge of how to scale a particular part of their stack. This was an awesome story from a small team having to tackle those challenges, and how they were learning as they went. So, while there are some of those "can't you just", and "whats interesting about this?" comments here, with the narrative of the growth rate, and the very high profile of the product, it was the perfect user talk for a internal development focused conference.

The key insight, and main message, of the talk was that if you are not too write heavy you can scale Postgres to very high read throughput with read replicas and only a single master! That is exactly the message that needs to be spelled out as that covers the vast majority of apps.

As an observation, in the Q&A at the end of the talk the questions, primarily from core Postgres developers, were focused on learning about the use case, and not an opportunity to suggest that they were doing anything wrong (not quite the same as this thread could get). A genuinely awesome group of very friendly and welcoming people in the Postgres community.

samwillis··on Local-First and Ejectable
I think this is a subset of the fifth (of the seven) ideals of local-first software https://www.inkandswitch.com/local-first/#5-the-long-now

> Local-first software enables greater longevity because your data, and the software that is needed to read and modify your data, are all stored locally on your computer.

There are many ways to achieve this goal - open document standards, open source servers, a escrowed release of the server, or this idea of a bail out system for taking the current version and self hosting it. All are commendable.

Actually achieving all seven ideals is hard, and there isn't much modern software that does it. But in my view anyone trying to achieve even a few of the ideals is making strides towards a worthy goal.

There is a lot of exciting stuff happening in the local-first software movement at the moment, and a lot of that is related the sync engines that are being built (disclaimer: I work for ElectricSQL, we are building one). These sync engine don't inherently make your software local-first, fitting all the ideals, but they do make it a lot easer to do so. They are an important building block. But there is more needed, we need more open document standards - Automerge, Yjs, Loro and the other CRDT data structures are perfect lower level data structures to build these higher level abstractions on. Martin Kleppmann has talked quite a bit about sync engines that are disconnected from the underlying application, essentially pluggable sync engine, you choose who to use to sync you copy of a document or application - I'm excited to see where this goes.

But, we also need to free up the application distribution platform. The app stores are walled gardens that prevent some business models, native apps (while performant) are tied to a specific platform (or even version!), and the web is inherently tied to servers and browsers. The web platform though, i.e. JS, HTML, CSS, is perfect for building high longevity software that runs anywhere, on any device, the issue is the distribution. We need a middle ground, an application package that built on web standards, but isn't tied to a server. I want to download a bundled app to my machine and have a copy, email to a family member, or even open and hack on it. Thats the final missing piece.

A downloadedable app, with an open and pluggable sync engine would achieve the same goles of this ejectable idea.

samwillis··on Posthog/.cursorrules
Cursor Compose (essentially a chat window) in YOLO mode.

Describe what you want, get it to confirm a plan, ask it to start, and go make coffee.

Come back 5min later to 1k lines of code plus tests that are passing and ready for review (in a nice code review / diff inline interface).

(I've not used copilot since ~October, no idea if it now does this, but suspect not)

samwillis··on A Letter to the American People
I'm not American, but I'm very aware of the impact 18f has had from seeing the many posts on here of their work over the years: https://hn.algolia.com/?q=18f

I'm also aware of at least a handful of hacker new members, and people I've followed, who took time out of their carriers to do a "tour of duty" at 18f.

I feel for all today, you were doing good work!

samwillis··on Ask HN: Is anyone still using Dreamweaver?
If you hadn't post this comment, I would have.

Fireworks could have been Figma, it could have been the default platform every designer used. But Adobe didn't understand it, they saw it as a weird Photoshop competitor and shelved it.

The last few versions bundled with CS were clearly neglected maintenance releases. I finally stopped using my slowing rotting copy in about 2014 when I got a Mac with a retina screen and fireworks was stuck with a terrible pixel doubled ui. :-(

samwillis··on Caddy – The Ultimate Server with Automatic HTTPS
Yep, it's really disappointing they didn't decide to support it for localhost.
samwillis··on Caddy – The Ultimate Server with Automatic HTTPS
One area we have found Caddy invaluable is for local testing of APIs with HTTP2 during development. Most dev servers are HTTP1 only, and so you are limited to max of 6 concurrent connections to localhost. HTTP2 requires SSL, which would normally make it a PITA to test/setup locally for development.

Throw a Caddy reverse proxy in front of your normal dev server and you immediately get HTTP2 via the root certificate it installs in your OS trust store. (https://caddyserver.com/docs/automatic-https)

We (ElectricSQL) recommend it for our users as our APIs do long polling, which with HTTP2 doesn't lock up those 6 concurrent connections.

I've also found that placing it in front of Vite for normal development makes reloads much faster. Vite uses the JS module system for loading individual files in the browser with support for HMR (hot module replacement), this can result in a lot of concurrent requests for larger apps, creating a queue for those files on the six connections. Other bundlers/build tools bundle the code during development, reducing the number of files loaded into the browser, this created a bit of a debate last year on which is the better approach. With HTTP2 via Caddy in front of Vite you solve all those problems!

samwillis··on United States Power Outage Map
The link is to their poweroutage.us, but they also cover Canada (https://poweroutage.com/ca), the UK (https://poweroutage.com/uk) and the EU (https://poweroutage.com/eu). For some reason they don't link to these from the US site.

Really interesting data, particularly when you compare the very low level of outages in Canada/UK compared with the US.

samwillis··on Live London Underground / bus maps taken down by TfL trademark complaint
s/autistic/artistic

I violated my own rule of always re-reading a post 5 min after posting it...

samwillis··on Live London Underground / bus maps taken down by TfL trademark complaint
It should be easy for a human at TfL to make an assessment on something like this, see the autistic and technical value, and offer a free but heavily restricted license to the developer.

But is suppose many organisations just don't give people the autonomy and authority to do such tings.

samwillis··on Database mocks are not worth it
Unit tests work well with PGlite, at least in the TS/JS world where it natively sits at the moment. You can have a unique Postgres instance for each unit test that's up and running in just a few ms.

It's possible to use PGlite from any language using native Postgres clients and pg-gateway, but you lose some of the nice test DX when it's embed directly in the test code.

I'm hopeful that we can bring PGlite to other platforms, it's being actively worked on.

The other thing I hope we can look at at some point is instant forks of in memory databases, it would make it possible to setup a test db once and then reset it to a known state for each test.

(I work on PGlite)

samwillis··on Punch (1844) predicts LLMs: "The new patent novel writer"
Sadly HN has stripped the fragment from the URL, see page 268: https://babel.hathitrust.org/cgi/pt?id=mdp.39015055216876&se...
samwillis··on Tldraw Computer
Very much this! I was also at a thing at their office a few weeks ago (some thing? "Local Thirst"), and Steve gave a demo of this. It is incredible.

I've joked before that the last generation of human machine interfaces ware invented at Xerox park, and the next generation is being invented at TLDraw of Finsbury Park. But it's not really a joke, I genuinely believe it.

samwillis··on In Search of a Faster SQLite
This is a great article.

There was a previous attempt to bring async io to Postgres, but sadly it went dormant: https://commitfest.postgresql.org/34/3316/

A more recent proposal was to make it possible to swap out the storage manager for a custom one without having to fork the codebase. I.e. extensions can provide an alternative. https://commitfest.postgresql.org/49/4428/

This would allow for custom ones that do async IO to any custom storage layer.

There are a lot of interested parties in the new proposal (it's come out of Neon, as they run a fork with a custom storage manager). With the move to separate compute from storage this becomes something many Postgres orgs will want to be able to do.

A change of core to use async io becomes slightly less relevant when you can swap out the whole storage manager.

(Note that the storage manager only handles pages in the heap tables, not the WAL. There is more exploration needed there to make the WAL extendable/replaceable)

samwillis··on Electric (Postgres sync engine) beta release
Hey, it's possible to use PGlite on the client, along with Drizzle. Our "Linearlite" example show this (albeit without Drizzle) with a "write through the database" pattern to sync back to the server.

Live demo: http://linearlite.examples.electric-sql.com

Code: https://github.com/electric-sql/electric/tree/main/examples/...

samwillis··on Electric (Postgres sync engine) beta release
Dynamic linking on iOS is complex, and Android also brings some toolchain complexities. It would be possible to do a native build and link it, and that is a route we are also exploring, but a single C file that can be linked with any existing toolchain would simplify things for users.

It also allows us to implement a VFS layer underneath PGlite in a native mode. So things like the in-memory VFS, or a custom VFS, would be possible.

We have not committed to one route or the other yet.

samwillis··on Electric (Postgres sync engine) beta release
A couple of things here:

- the WASI build is targeting WASI snapshot preview 1, and so should work in any compatible runtime.

- for the web, currently we use Emscripten, but we are considering moving to a single WASI build there as well. We'll be writing our own JS WASI shim if we do. Having full control of the JS code will help to solve some of the problems we've faced with Emscripten.

- we are also exploring a route to native where we take the WASI build and decompile it back to C. This seems a little mad, but it makes it possible to compile (with any tool chain) a native binary with a very minimal WASI-like api that can be linked to from any app. It essentially end up a little like the SQLite amalgamated header file as a build route. It's very experimental, and we haven't committed to it yet, but it looks like it may work.

samwillis··on Starlink Direct to Cell
It's similar (ish), but I think unfortunately the comparison distracts from your core point and observation.

Musk Inc. is, in essence, a privet equity company. He raises a fund, and invests it along with his own cash into a business he knows well, and with which he believes he can disrupt the status quo.

He's very hands on, understanding all the important core details, setting culture, and pushing hard. But he also delegates to experts he brings in to run his businesses.

It's obviously not the same as PE, but there are distinct similarities. With each of his companies he clearly can't take an active role all the time, but what his team are experts at is identifying the areas he needs to be on top of, and they will quite literally fly him in for it. It seems to me it's always the start of something, be it a new company or project. He will be there 24/7 getting it off the ground, but then hand over to lieutenants to run.

It's a formula that seems to work again and again. We're (well those of you in the US) are in for an interesting time over the coming year as he has a new project to kick start.

samwillis··on Which power plant does my electricity come from?
Yep, there are on-shore plans, but there is a lot of NIMBYism that results a resistance to these necessary projects.
samwillis··on Google's new pipe syntax in SQL
Richard Hipp, creator of SQLite, has implemented this in an experimental branch: https://sqlite.org/forum/forumpost/5f218012b6e1a9db

Worth reading the thread, there are some good insights. It looks like he will be waiting on Postgres to take the initiative on implementing this before it makes it into a release.

samwillis··on Many small queries are efficient in SQLite
I love this explanation.

It's interesting to consider the question of what this would look like if you put Postgres, rather than SQLite, in process? With PGlite we can actually look at it.

I'm hesitant to post a link to benchmarks after the last 24 hours on Twitter... but I have some basic micro-benchmarks comparing WASM SQLite to PGlite (WASM Postgres that runs in-process): https://pglite.dev/benchmarks#round-trip-time-benchmarks

It's very much in the same ballpark, Postgres is a heavier databases and is understandably slower, but not by much. There is a lot of nuance to these benchmarks though as the underlying VFSs are a little different to each other, and PGlite has a WAL rather then SQLite which is in its rollback journal mode (I believe this is why PGlite is faster for some inserts/updates).

But essentially I think Postgres when in-process would be able to perform similarly to SQLite with many small queries and embracing n+1. But having said that I think the other comments here about query planning are important to consider, if you can minimise your queries, you minimise the scans of indexes and tables, which is surely better.

What this does show, particularly when you look at the "native" comparison at the end, is that removing the network (or at least a local socket) from the stack being the two closer together.

samwillis··on Postgres as a Search Engine
While both points are true now, there is a lot of work happing to bring both column storage and separate compute and storage to Postgres.

The pg_duck project has the eventual aim to implement a column storage engine for Postgres. There are a few steps to get there as it needs to be tied into the Postgres page storage and replication system. So it's not solved by the first version of pg_duck, but the team is incredible and I believe it will happen.

Neon and Oriole (acquired by Supabase) are both open source and separate storage and compute. There is a few steps more for them to go to be truly usable self hosted, but they will get there, and some of the work they are doing will hopefully be upstreamed.

samwillis··on Playing Sudoku in TypeScript while the type checker highlights mistakes
This is super cool, love these sort of projects.

It's crazy what you can achieve with typescript types, what about inferring sql query results types from a raw sql query string: https://github.com/nikeee/sequelts

samwillis··on We need to liberate the Postcode Address File
Sadly I don't think this would happen, particularly if Ordnance Survey is responsible, all their data is paid for access.

We have a very different model for access to data produced by government agency use to that in the US.

USGS Topographic maps: public domain / free

UK OS Topographic maps: paid access, and it's not cheep

US National Weather Service: Public domain / free commercial use

UK MetOffie: Payed access for commercial use

samwillis··on Sonos CEO says the old app can't be rereleased
Yeh, I don't think it's the tech choice that's the problem. It's the choice to change the tech that has caused this.

A clean rewrite of a wireless networking stack that does real-time synced audio streaming and device discovery on any users home WiFi (which is notoriously bad!) is a decision to face a lot of pain finding the edge cases that were previously fixed 10y ago.

samwillis··on Sonos CEO says the old app can't be rereleased
This is a really good summary of what's technically changed inside the Sonos system, and how it's caused a lot of these problem: https://www.linkedin.com/pulse/what-happened-sonos-app-techn...

Essentially they replaced the 15 year old, and incredibly robust network based on UPnP, with a new system using mDNS+HTTP+Websockets. And at the same time stuck their cloud in the loop for connecting to third party music services.

It's resulted in a much more fragile networking stack, far more prone to incompatibilities with users WiFi configurations. Which due to being so much heavier, some of their older hardware may struggle with. And that's all before you consider the UX changes in the app, and the missing functionality (how do you release a forced upgrade before finishing all old, and essential, functionality?!)

I assume that they have started removing some/all of the old code from the speakers which makes the old app incompatible.

samwillis··on Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
This looks like a great task queue, I'm a massive proponent of "Postgres is all you need" [0] and doubling down on it with my project that takes it to the extreme.

What I would love is a Postgres task queue that does multi-step pipelines, with fan out and accumulation. In my view a structured relational database is a particularly good backend for that as it inherently can model the structure. Is that something you have considered exploring?

The one thing with listen/notify that I find lacking is the max payload size of 8k, it somewhat limits its capability without having to start saving stuff to tables. What I would really like is a streaming table, with a schema and all the rich type support... maybe one day.

0: https://www.amazingcto.com/postgres-for-everything/

samwillis··on Just use Postgres
Yep, we are actively working on native support.

(I work on PGlite)

samwillis··on VanillaJSX.com
The virtual dom makes implementing a declarative templating system easer, and declarative templates are easer for a developer to reason about, and less error prone, than having to mutate the dom directly.

People often mistakingly describe the vdom as faster than the dom, this is incorrect. It would be faster than throwing away the whole components dom and rebuilding, so the same templating code building a new dom, rather than a vdom that's then diffed. Hand crafter mutations will be faster than a vdom diff, simply because the computer is doing les work, however much more error prone.

← PreviousPage 3 of 34Next →