Live data from Hacker News

Cap'n Web: a new RPC system for browsers and web servers

blog.cloudflare.com

231–240 of 305 posts

Re: Cap'n Web: a new RPC system for browsers and web servers

#231
post #201
post #122

Earlier quoted context omitted.

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…

Can’t you just write everything default-async and then if you want sync behavior just await immediately?

that is terrible for performance and some operations have external requirements to be sync

Re: Cap'n Web: a new RPC system for browsers and web servers

#232
post #57

The section on how they solved arrays is fascinating and terrifying at the same time https://blog.cloudflare.com/capnweb-javascript-rpc-library/#... . > .map() is special. It does not send JavaScript code to the server, but it does send something like "code", restricted to a domain-specific, non-Turing-complete language. The "code" is a list of instructions that the server should carry out for each member of the arra…

I kind of want to see an ORM try something like this.

You can't do this in most languages because of if statements, which cannot be analyzed in that way and break the abstraction. You'd either need macro-based function definitions (Lisp, Elixir), bytecode inspection (like in e.g. Pytorch compile), or maybe built-in laziness (Haskell).

Edit: Or full object orientation like in Smalltalk, where if statements are just calls to .ifTrue and .ifFalse on a true/false object, and hence can be simulated.

Re: Cap'n Web: a new RPC system for browsers and web servers

#233
post #57

The section on how they solved arrays is fascinating and terrifying at the same time https://blog.cloudflare.com/capnweb-javascript-rpc-library/#... . > .map() is special. It does not send JavaScript code to the server, but it does send something like "code", restricted to a domain-specific, non-Turing-complete language. The "code" is a list of instructions that the server should carry out for each member of the arra…

So now I have yet another colour of function? Fun.

Re: Cap'n Web: a new RPC system for browsers and web servers

#234
post #57

The section on how they solved arrays is fascinating and terrifying at the same time https://blog.cloudflare.com/capnweb-javascript-rpc-library/#... . > .map() is special. It does not send JavaScript code to the server, but it does send something like "code", restricted to a domain-specific, non-Turing-complete language. The "code" is a list of instructions that the server should carry out for each member of the arra…

That's neat, tnx for pointing it out

Re: Cap'n Web: a new RPC system for browsers and web servers

#235

Earlier quoted context omitted.

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).

> Is there anything C# _doesn’t_ have? Pi types, existential types and built-in macros to name a few.

Sum types are the ones I really miss. The others would be nice but processing heterogeneous streams is my biggest practical issue.

Re: Cap'n Web: a new RPC system for browsers and web servers

#236
On the path they've started with pipelining calls parametric on previous calls, they'll quickly realize that eventually they'll need basic transforms on the output before they pass it as input i.e. necessitating support for a standard runtime with a standard library of features.

I.e. imagine you need this:

    promise1 = foo.call1();
    promise2 = foo.call2();
    promise3 = foo.call2(promise1 + promise2);
Can't implement that "+" there unless...

    promise1 = foo.call1();
    promise2 = foo.call2();
    promise3 = foo.add(promise1, promise2)
    promise4 = foo.call2(promise3);
You can also make some kind of a RpcNumber object so you can use their Proxy function to do promise1.add(promise2) but ultimately you don't want to write such classes on the spot every time. Or functions on the server for it.

The problem is even that won't give you conditions (loops, branches) that run on the server, the server execution is blocked by the client.

Once you realize THAT, you realize it's most optimal if both sides exchange command buffers in general, including batch instructions to remote and local calls and standardized expression syntax and library.

What they did with array.map() is cute but it's not obvious what you can and what you can't do with this, and most developers will end up tripping up every time they use it, both trying to overuse this feature and underusing it, unaware of what it maps, how, when and where.

For example this record replay can't do any (again...) arithmetic, logic, branching and so on. It can record calling method on the Proxy and replaying this on the other side, in simple containers, like an object literal.

This is where GraphQL is better because it's an explicit buffer send and an explicit buffer return. The number of roundtrips and what maps how is not hidden.

GraphQL has its own mess of poorly considered features, but I don't think Cap'n Web survives prolonged contact with reality because of how implicit and magical everything is.

When you make an abstraction like this, it needs to work ALL THE TIME, so you don't have to think about it. If it only works in demo examples written by developers who know exactly when the abstraction breaks, real devs won't touch it.

Re: Cap'n Web: a new RPC system for browsers and web servers

#237

Earlier quoted context omitted.

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).

It's one of the most widely used languages out there actually. But it's primarily used at buttoned up and boring SMB's/enterprise backoffices. We're not out here touting our new framework of the month to kafloogle the whatzit. We're just building systems with a good language and ecosystem that's getting better every year. I've worked only at startups/small businesses since I graduated university and it's all been in…

getting better? many packages we been using did a license swap on us xD

fucking nice ecosystem

Re: Cap'n Web: a new RPC system for browsers and web servers

#238

I'm with WunderGraph, a vendor providing enterprise tooling for GraphQL. First, I absolutely love Capn Proto and the ideas of chaining calls on objects. It's amazing to see what's possible with CapNweb. However, one of the examples compares it to GraphQL, which I think falls a bit short of how enterprises use the Query language in real life. First, like others mentioned, you'll have N+1 problems for nested lists. Tha…

> First, like others mentioned, you'll have N+1 problems for nested lists. That is, if we call comments() on each post and author() on each comment, we absolutely don't want to have one individual call per nested object. In GraphQL, with the data loader pattern, this is just 3 calls.

Why is that a problem? As far as I can tell, those calls are all done on the server, where they're cheap normal function calls, and the results are all sent back with 1 roundtrip; because of the pipelining.

Re: Cap'n Web: a new RPC system for browsers and web servers

#239
post #90

Earlier 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).

>Is there anything C# _doesn’t_ have?

You were maybe already getting at it, but as a kitchen sink language the answer is "simplicity". All these diverse language features increase cognitive load when reading code, so it's a complexity/utility tradeoff

Re: Cap'n Web: a new RPC system for browsers and web servers

#240

I'm with WunderGraph, a vendor providing enterprise tooling for GraphQL. First, I absolutely love Capn Proto and the ideas of chaining calls on objects. It's amazing to see what's possible with CapNweb. However, one of the examples compares it to GraphQL, which I think falls a bit short of how enterprises use the Query language in real life. First, like others mentioned, you'll have N+1 problems for nested lists. Tha…

> First, like others mentioned, you'll have N+1 problems for nested lists. That is, if we call comments() on each post and author() on each comment, we absolutely don't want to have one individual call per nested object. In GraphQL, with the data loader pattern, this is just 3 calls. Why is that a problem? As far as I can tell, those calls are all done on the server, where they're cheap normal function calls, and the…

Because they each result in round-trips and individual queries to the database rather than a more efficient single round-trip with a join. Note: I don't know the details of GraphQL, but I'm assuming it does the smarter thing.

In this paradigm, the places where you are calling map() could probably be replaced with explicit getComments() or getCommentsWithAuthors() or two methods that do just one query each.

Post reply on HN