-
Notifications
You must be signed in to change notification settings - Fork 17
Transit
Transit is a format and set of libraries for conveying values between applications written in different programming languages. The key objectives of Transit are to support:
- context-free interpretation
- generic extensibility
- good performance (including web browsers)
Data often requires context for interpretation, which can lead to brittle programs. The context can be in a programmer's head, e.g. "Values under the beginAt key are strings that need to be converted into dates", or the context can be encoded into a schema, shipped either with the data or via a separate channel.
Such context increases the burden on programs that would consume data. Moreover, this burden worsens substantially in large, dynamic systems. Intermediate processing steps cannot be written generically, because they must know not just 1 but N (or NxM) different contexts.
Transit provides a rich set of values that can be understood without additional context or schemas.
Users need their own data types. If a data framework is not extensible, these data types will have to be determined via context, undermining the benefits established above.
Transit provides generic extensibility:
- New types are defined in terms of existing types.
- Transit implementations can generically handle types whose definitions they have not seen.
The latter property is particularly important, because it allows you to evolve "smarter" processes without breaking "dumber" processes that are already part of a working system.
Web browsers provide optimized support for reading and writing JSON, and any data encoding that needs to reach the browser will inevitably be compared to JSON, both for convenience and performance.
Transit achieves performance (and facilitates new implementations) by building on top of existing, optimized formats: JSON and MessagePack. In fact, Transit's caching means that Transit can be faster than JSON, even when calling the JSON parser internally.