annotate src/capnproto-0.6.0/doc/_posts/2013-09-04-capnproto-0.3-python-tools-features.md @ 83:ae30d91d2ffe

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