Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
kentonv
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
13 ms
·
241.
▲
by
kentonv
1y ago
The round trip happens when you `await` the result. You can tell that promise pipelining isn't adding any round trips because you set it all up in a series of statements without any `await`s. At the end you do one `await`. That's
242.
▲
by
kentonv
1y ago
I think any other syntax would likely be cumbersome. What we actually want to express here is function-shaped: you have a parameter, and then you want to substitute it into one or more RPC calls, and then compute a result. If you're go
243.
▲
by
kentonv
1y ago
That is actually pretty interesting! Have you considered making a sqlite version that works in Durable Objects? :)
244.
▲
by
kentonv
1y ago
Yes, perhaps. Particularly if it's the exact same function (by identity). It hadn't occurred to me.
245.
▲
by
kentonv
1y ago
Hmm, but I should make it so the map callback can take the index as the second parameter probably. Of course, it would actually be a promise for the index, so you couldn't compute on it, but there might be other uses...
246.
▲
by
kentonv
1y ago
I'm thinking the ideal would be if I could feed in a TypeScript interface, and have some tool generate a wrapper around that interface which type-checks all inputs. This tool could actually be totally independent from the RPC implement
247.
▲
by
kentonv
1y ago
Yes, pretty much. Just interfacing between the JS app and the Wasm RPC implementation would take more code than the entire RPC implementation in TypeScript. Also, the audience of this library is very specifically TypeScript developers. If y
248.
▲
by
kentonv
1y ago
Because JSON serialization is built into the browser. I'm obviously a huge fan of binary serialization; I wrote Cap'n Proto and Protobuf v2 after all. But when you're working with pure JS, it's hard to be much faster tha
249.
▲
by
kentonv
1y ago
The Cloudflare Workers runtime is 1000x more complicated than your average web application. :)
250.
▲
by
kentonv
1y ago
I said that shared state between connections is rare, but shared state within a connection is extremely common. And there are still multiple concurrent things going on within that connection context, requiring some concurrency mechanism
251.
▲
by
kentonv
1y ago
I believe this will stack-overflow on the client side. The callback is invoked in recording mode synchronously when you call `.map()`. Nested maps are allowed, but this case ends up being infinitely nested, so eventually you're going t
252.
▲
by
kentonv
1y ago
I really want to bake in some sort of support for generating type checks based on TypeScript types... so then your schemas are just TypeScript. Not sure why this doesn't seem to be a common practice TBH, might be missing something.
253.
▲
by
kentonv
1y ago
I agree that, in the abstract, it's inconsistent. But in the concrete: * Looking up some additional data for each array element is a particularly common thing to want to do. * We can support it nicely without having to create a library
254.
▲
by
kentonv
1y ago
Yes, in principle, any sort of remote compute we want to support, we could accomplish by having a custom function you have to call for it. Then the calls can be captured into the record. But also, apps can already do this themselves . Sinc
255.
▲
by
kentonv
1y ago
I think Mark S Miller beat us both by like 10-20 years with CapTP. ;)
256.
▲
by
kentonv
1y ago
I disagree that async/await is purely about avoiding overhead of kernel threads. Kernel threads are actually not that expensive these days. You can have a server with 10,000 threads, no problem. The problem is synchronization becomes e
257.
▲
by
kentonv
1y ago
Some of the tests are LLM-generated, but none of the library itself is. I don't think LLMs would be capable of writing this library (at least at present). The pieces fit together like a very intricate puzzle. I spent a lot more time th
258.
▲
by
kentonv
1y ago
See cousin comment: https://news.ycombinator.com/item?id=45338969
259.
▲
by
kentonv
1y ago
I don't think you could make filter() work with the same approach, because it seems like you'd actually have to do computation on the result. map() works for cases where you don't need to compute anything in the callback, you
260.
▲
by
kentonv
1y ago
> I wonder why they don't just do `.toString()` on the mapping function and then parse the resulting Javascript into an AST and figure out property accesses from that. That sounds incredibly complicated, and not something we could d
261.
▲
by
kentonv
1y ago
The placeholder value is an RpcPromise. Which means that all its properties are also RpcPromises. So `p.IsPerson` is an RpcPromise. I guess that's truthy, so the expression will always evaluate to `(p.FirstName + ' ' + p.Last
262.
▲
by
kentonv
1y ago
> So it's basically Stubby/gRPC. Stubby / gRPC do not support object capabilities, though. I know that's not what you meant but I have to call it out because this is a huuuuuuuge difference between Cap'n Proto&#x
263.
▲
by
kentonv
1y ago
I'll be honest and say I haven't tried it myself. But my expectation is you'd use Zod to define all your parameter types. Then you'd define your RpcTarget in plain TypeScript, but for the parameters on each method, refer
264.
▲
by
kentonv
1y ago
I haven't actually used tRPC nor oRPC. But my understanding is that neither of them support object-capabilities nor promise pipelining. These are the killer features of Cap'n Web (and Cap'n Proto), which the blog post describ
265.
▲
by
kentonv
1y ago
No. Zod gives you TypeScript types corresponding to the schema. So you would only need to write the schema in Zod. (I do wish it could be the other way, though: Write only TypeScript, get runtime checks automatically.)
266.
▲
by
kentonv
1y ago
That's a use case I'm actually already using it for. :) That's why the MessagePort transport is included.
267.
▲
by
kentonv
1y ago
FWIW, Cap'n Proto is a statically-typed version of this that has been around since 2013, and is actually used heavily in the implementation of Cloudflare Workers.
268.
▲
by
kentonv
1y ago
.map() is totally special-cased. For any other function accepting a callback, the function on the server will receive an RPC stub, which, when called, makes an RPC back to the caller, calling the original version of the function. This is us
269.
▲
by
kentonv
1y ago
You actually CAN close over RPC stubs. The library will capture any RPC calls made during the mapper callback, even on stubs other than the input. Those stubs are then sent along to the server with the replay instructions.
270.
▲
by
kentonv
1y ago
You can define a stream like: interface Stream extends RpcTarget { write(chunk): void; end(): void; [Symbol.dispose](): void; } Note that the dispose method will be called automatically when the caller dispose
More ›