I was thinking about writing a code generator to generate scala from google protobuf definitions file. The reason I see it valuable is the java bindings are too Java-ish and one could do much better in scala. For example for the following definition
message Foo {
required int F1 = 1;
repeated string F2 = 2;
message Inner (
required int F3 = 1;
)
}
I want to be able to construct the proto object from Scala like this:
val foo = Foo (
F1(127),
F2("first", "second"),
Inner (
F3(911)
)
)
My question is if anyone knows something along these lines already existing, or if not do you find it worthy to start a new project?
Google provides a compiler called protoc which can produce output for C++, Java or Python. Other schema compilers are available from other sources to create language-dependent output for over 20 other languages.
ScalaPB is a protocol buffer compiler ( protoc ) plugin for Scala. It will generate Scala case classes, parsers and serializers for your protocol buffers. ScalaPB generates case classes that can co-exist in the same project alongside the Java-generated code for ProtocolBuffer.
Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.
I'm currently working on a Scala Protocol Buffers compiler with my mentor Viktor Klang. It's my Google Summer of Code project and you can follow the progress on github at https://github.com/SandroGrzicic/ScalaBuff.
[Update] The main part is complete; I still need to implement Extensions, Groups and field Options support. It's usable and I invite everyone to try it and give feedback; I'm open to suggestions and feature requests.
I just came across these but can not vouch for them as I've never used them.
http://code.google.com/p/protobuf-scala/
https://github.com/jeffplaisance/scala-protobuf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With