Company
Date Published
Author
Kenton Varda and Steve Faulkner
Word count
2831
Language
English
Hacker News points
None

Summary

Cap'n Web is a new RPC protocol written in TypeScript, designed as a web-friendly counterpart to Cap'n Proto. It eliminates the need for schemas and boilerplate, using JSON for serialization and supporting HTTP, WebSocket, and postMessage for transport. Cap'n Web is lightweight, open source under the MIT license, and can be minified to under 10 kB. It enables bidirectional calling, passing functions and objects by reference, promise pipelining, and capability-based security patterns. This allows developers to design RPC interfaces similarly to JavaScript APIs while addressing network latency issues. Cap'n Web is compatible with TypeScript, enabling type-safe RPC API declarations. It offers an alternative to GraphQL by solving the "waterfall" problem in REST APIs without introducing new languages or ecosystems, allowing complex interactions to be modeled in JavaScript. Cap'n Web also introduces a novel way of handling arrays with a special `.map()` operation that enables server-side transformations without additional network round trips.