blob: 34a3f0656b0b8f843cd7386b6dd91c86627cff4a [file] [log] [blame] [view]
Kenton Varda89e1a2e2013-08-29 16:36:37 -07001---
2layout: post
3title: "Cap'n Proto v0.3: Python, tools, new features"
4author: kentonv
5---
6
7The first release of Cap'n Proto came three months after the project was announced. The second
8release came six weeks after that. And the third release is three weeks later. If the pattern
9holds, there will be an infinite number of releases before the end of this month.
10
11Version 0.3 is not a paradigm-shifting release, but rather a slew of new features largely made
12possible by building on the rewritten compiler from the last release. Let's go through the
13list...
14
Kenton Varda7739b532013-09-03 20:26:38 -070015### Python Support!
Kenton Varda89e1a2e2013-08-29 16:36:37 -070016
17Thanks to the tireless efforts of contributor [Jason Paryani](https://github.com/jparyani), I can
18now comfortably claim that Cap'n Proto supports multiple languages. [His Python
Kenton Vardabc0dd4a2013-09-01 11:11:43 -070019implementation](http://jparyani.github.io/pycapnp/) wraps the C++ library and exposes
Kenton Varda89e1a2e2013-08-29 16:36:37 -070020most of its features in a nice, easy-to-use way.
21
22And I have to say, it's _way_ better than the old Python Protobuf implementation that I helped put
23together at Google. Here's why:
24
25* Jason's implementation parses Cap'n Proto schema files at runtime. There is no need to run a
26 compiler to generate code every time you update your schema, as with protobufs. So, you get
Kenton Varda7739b532013-09-03 20:26:38 -070027 to use Python the way Python was intended to be used. In fact, he's hooked into the Python
28 import mechanism, so you can basically import a `.capnp` schema file as if it were a `.py`
29 module. It's even convenient to load schema files and play with Cap'n Proto messages from the
30 interactive interpreter prompt.
Kenton Varda89e1a2e2013-08-29 16:36:37 -070031* It's _fast_. Whereas the Python Protobuf implementation -- which we made the mistake of
32 implementing in pure-Python -- is _slow_. And while technically there is an experimental
33 C-extension-based Python Protobuf implementation (which isn't enabled by default due to various
34 obscure problems), Jason's Cap'n Proto implementation is faster than that, too.
35
Kenton Vardabc0dd4a2013-09-01 11:11:43 -070036Go [check it out](http://jparyani.github.io/pycapnp/)!
Kenton Varda89e1a2e2013-08-29 16:36:37 -070037
38By the way, there is also a budding [Erlang implementation](http://ecapnp.astekk.se/)
39(by Andreas Stenius), and work
40continues on [Rust](https://github.com/dwrensha/capnproto-rust) (David Renshaw) and
41[Ruby](https://github.com/cstrahan/capnp-ruby) (Charles Strahan) implementations.
42
Kenton Varda7739b532013-09-03 20:26:38 -070043### Tools: Cap'n Proto on the Command Line
Kenton Varda89e1a2e2013-08-29 16:36:37 -070044
45The `capnp` command-line tool previously served mostly to generate code, via the `capnp compile`
46command. It now additionally supports converting encoded Cap'n Proto messages to a human-readable
47text format via `capnp decode`, and converting that format back to binary with `capnp encode`.
48These tools are, of course, critical for debugging.
49
50You can also use the new `capnp eval` command to do something interesting: given a schema file and
51the name of a constant defined therein, it will print out the value of that constant, or optionally
52encode it to binary. This is more interesting than it sounds because the schema language supports
53variable substitution in the definitions of these constants. This means you can build a large
54structure by importing smaller bits from many different files. This may make it convenient to
55use Cap'n Proto schemas as a config format: define your service configuration as a constant in
56a schema file, importing bits specific to each client from other files that those clients submit
57to you. Use `capnp eval` to "compile" the whole thing to binary for deployment. (This has always
58been a common use case for Protobuf text format, which doesn't even support variable substitution
59or imports.)
60
Kenton Vardac5de5bc2013-08-31 19:20:18 -070061Anyway, check out the [full documentation]({{ site.baseurl }}capnp-tool.html) for
Kenton Varda89e1a2e2013-08-29 16:36:37 -070062more.
63
Kenton Varda7739b532013-09-03 20:26:38 -070064### New Features
Kenton Varda89e1a2e2013-08-29 16:36:37 -070065
66The core product has been updated as well:
67
Kenton Vardac5de5bc2013-08-31 19:20:18 -070068* Support for unnamed [unions]({{ site.baseurl }}language.html#unions) reduces the
Kenton Varda89e1a2e2013-08-29 16:36:37 -070069 need for noise-words, improving code readability. Additionally, the syntax for unions has been
70 simplified by removing the unnecessary ordinal number.
Kenton Vardac5de5bc2013-08-31 19:20:18 -070071* [Groups]({{ site.baseurl }}language.html#groups) pair nicely with unions.
72* [Constants]({{ site.baseurl }}language.html#constants) are now
73 [implemented in C++]({{ site.baseurl }}cxx.html#constants). Additionally, they
Kenton Varda89e1a2e2013-08-29 16:36:37 -070074 can now be defined in terms of other constants (variable substitution), as described earlier.
75* The schema API and `schema.capnp` have been radically refactored, in particular to take advantage
76 of the new union and group features, making the code more readable.
77* More and better tests, bug fixes, etc.
78
Kenton Varda7739b532013-09-03 20:26:38 -070079### Users!
Kenton Varda89e1a2e2013-08-29 16:36:37 -070080
81Some news originating outside of the project itself:
82
Kenton Varda7739b532013-09-03 20:26:38 -070083* [Debian Unstable (sid)](http://www.debian.org/releases/sid/) now features
84 [a Cap'n Proto package](http://packages.debian.org/sid/capnproto), thanks to
85 [Tom Lee](https://github.com/thomaslee). Of course, since package updates take some time, this
86 package is still v0.2.1 as of this writing, but it will be updated to v0.3 soon enough.
Kenton Varda89e1a2e2013-08-29 16:36:37 -070087* Popular OSX-based text editor [TextMate](http://macromates.com/) now
88 [uses Cap'n Proto internally](https://github.com/textmate/textmate/commit/5c02b4ff5cc0c7c319d3d4f127c8ee19b81f80b7),
89 and the developer's feedback lead directly to several usability improvements included in this
90 release.
91* Many people using Cap'n Proto _haven't bothered to tell us about it_! Please, if you use it,
92 [let us know](https://groups.google.com/group/capnproto) about your experience, both what you like
93 and especially what you don't like. This is the critical time where the system is usable but
94 can still be changed if it's not right, so your feedback is critical to our long-term success.
95* I have revenue! A whopping [$1.25 per week](https://www.gittip.com/kentonv/)! >_> It's
96 totally worth it; I love this project. (But thanks for the tips!)