- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
[protobuf] [ANN] scala protobuf builder 0.1
Thu, 2010-08-19, 11:09
Hi all,
I'm pleased to announce the birth of scala-protobuf project. You can
find the sources at http://code.google.com/p/protobuf-scala .
The goal of the project is allowing easy construction of Google
protobuf (http://code.google.com/p/protobuf/) messages from Scala.
Unlike conventional protobuf code, protobuf-scala allows for a more
code-as-data way to write your protocol messages. Here is a short
example.
Given a protocol definition
message Artist {
required string name = 1;
message Album {
required string title = 1;
repeated string tracks = 2;
optional uint32 year_produced = 3;
}
repeated Album albums = 2;
}
one creates instances like this:
val BradMehldau = Artist (
name("Brad Mehldau"),
albums (
Album (
title("Day Is Done"),
tracks(
"50 ways to leave your lover",
"Grenada"
),
year_produced(2005)
)
)
)
As most of scalac plugins, protobuf-scala consists of a generator
plugin and a thin runtime layer in scala. The output of scala code
generator requries java classes produced with --java_output, so be
sure to produce it as well.
Hope those of you who use both scala and protobufs find it useful.
Cheers,
Eugene.