Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala protocol buffers compiler

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?

like image 561
venechka Avatar asked Aug 04 '10 07:08

venechka


People also ask

What does protoc compiler do?

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.

What is Scala PB?

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.

Is Protocol a buffer binary?

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.


2 Answers

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.

like image 151
Sandro Gržičić Avatar answered Nov 03 '22 01:11

Sandro Gržičić


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

like image 32
stevie el Avatar answered Nov 03 '22 00:11

stevie el