Earlier quoted context omitted.
Async/await became ergonomic and widespread only recently, I am sure there were async systems in the '80 but for example nodejs focus on non blocking I/O changed how a lot of people thought about servers and concurrency (whether node was first is almost irrelevant) Often when something is discovered or invented is far less influential[1] than when it jumps on and hype train. [1] the discovery is very important for hi…
I actually hate async/await approach to concurrency and avoid it as much as I can. My mental model is that it's a caller who decides how call should be executed (synchroniously or asynchroniously). Synchronious call is when caller waits till completion/error, asynchronious - is when caller puts the call in the background (whatever it means in that language/context) and handle return results later. CSP concurrency mod…
Cap'n Web: a new RPC system for browsers and web servers
201–210 of 305 posts
Re: Cap'n Web: a new RPC system for browsers and web servers
#202Tangential from a discussion in TFA about GraphQL: > One benefit of GraphQL was to solve the “waterfall” problem of traditional REST APIs by allowing clients to ask for multiple pieces of data in one query. For example, instead of making three sequential HTTP calls: GET /user GET /user/friends GET /user/friends/photos …you can write one GraphQL query to fetch it all at once. Or you could have designed a schema to all…
Huh that sounds a lot like graphql
Re: Cap'n Web: a new RPC system for browsers and web servers
#203I see that it supports websockets for the transport layer, is there any support for two way communication? edit: was skimming the github repo https://github.com/cloudflare/capnweb/tree/main?tab=readme-o... and saw this which answers my question: > Supports passing functions by reference: If you pass a function over RPC, the recipient receives a "stub". When they call the stub, they actually make an RPC back to you, i…
Re: Cap'n Web: a new RPC system for browsers and web servers
#204The main problem was always the same -- all the RPC libraries are designed to hide where the round-trip happens, but in real world you always want to know where and how the round-trip happens. Just read about Cap'n Web array .map() [1] -- it's hard to understand where the round-trip is. And that is not a feature, that's a bug -- in reality you want to easily tell what the code does, not hide it. [1] https://blog.clou…
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 your round trip.
Because if I understand correctly, you don't queue the requests and then perform a single request/response cycle (a "round trip"), you send a bunch of requests as they happen with no response expected, then when an await happens, you send a message saying "okay, that's all, please send me the result" and get a response.
Re: Cap'n Web: a new RPC system for browsers and web servers
#205This is quite interesting. However the abysmal pattern I have seen a number of times is:
list = getList(...) for item in list getItemDetails(item)
Sometimes this is quite hard to undo.
Re: Cap'n Web: a new RPC system for browsers and web servers
#206Earlier quoted context omitted.
Couldn’t you make this safer by passing the map something that’s not a plain JS function? I confess to that being the only thing that had me questioning the logic. If I can express everything, then everything should work. If it’s not going to work, I don’t want to be able to express it.
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 going to represent that with a bunch of data structures, you end up with a DSL-in-JSON type of thing and it's going to be unwieldy.
Re: Cap'n Web: a new RPC system for browsers and web servers
#207This is like .NET Remoting. Suggest resisting the temptation to use this kind of stuff. It gets very hard to reason about what is going on.
Re: Cap'n Web: a new RPC system for browsers and web servers
#208Earlier quoted context omitted.
In C#, there's expression trees which handle things like this and it's how Entity Framework is able to convert the lambdas it's given into SQL. This means that you can pass around code that can be inspected or transformed instead of being executed. Take this EntityFramework snippet: db.People.Where(p => p.Name == "Joe") `Where` takes an `Expression > predicate`. It isn't taking the `Func` itself, but an `Expression`…
Is there anything C# _doesn’t_ have? :-) It feels like C# has an answer to every problem I’ve ever had with other languages - dynamic loading, ADTs with pattern matching, functional programming, whatever this expression tree is, reflection, etc etc. Yet somehow it’s still a niche language that isn't widely used (outside of particular ecosystems).
Pi types, existential types and built-in macros to name a few.
Re: Cap'n Web: a new RPC system for browsers and web servers
#209Earlier quoted context omitted.
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 thinking about how to do it right, than actually coding. Very different from my workers-oauth-provider library, where it was just implementing a well-known spec with a novel (yet straight…
> There's a whole lot of iterating over arbitrary objects without knowing their types. That's just parametric polymorphism.
Those three words are doing a lot of work there.
Re: Cap'n Web: a new RPC system for browsers and web servers
#210>> If a class extends the special marker type RpcTarget, then instances of that class are passed by reference, with method calls calling back to the location where the object was created. This is like .NET Remoting. Suggest resisting the temptation to use this kind of stuff. It gets very hard to reason about what is going on.