views:

149

answers:

2

Hello, 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?

+3  A: 

There's this project that uses Simple-Build-Tool plugins to achieve that effect: http://github.com/codahale/protobuf-sbt?locale=sv

Viktor Klang
Doesn't it generate java bindings?
venechka
A: 

Maybe it would be possible to write a Scala compiler plugin that read and compiled .proto files?

Magnus
It could be a proto compiler for scala. Open sourced Google code has backends for various programming languages.
venechka

related questions