Hacker News new | past | comments | ask | show | jobs | submit login

So how many programming languages besides LISP are powerful enough to support turning Protocol Buffers into code during compilation? And is this the ultimate must have?



It could be done in OCaml or Haskell, considering they both have compile-time AST generation/manipulation, but I'm not sure if anyone's written an actual implementation of this. Nimrod too, as that has AST macros. As does Elixir.


D, Rust, Nim(rod), Template Haskell, OCaml, C++...


I don't think these can open and read .proto files during compilation.


D has meta-programming and compile-time evaluation, including reading files.

I bet C++ can do it with some clear use of template metatprogramming, compile time evaluation and processor macros.

Nim has meta-programming capabilities, including reading files.

Not sure about Template Haskell, though.


Template Haskell code can runIO I/O actions, including reading files.


Rust can.


Are you referring to compiler plugins like the one providing regex! macro or is it something else?


Yes, compiler plugins. For a relevant example, check out the Rust docopt crate[1].

An identical technique could be used for yacc or protobufs.

[1]: https://github.com/docopt/docopt.rs


Haskell can, but there is not an implementation that does this.


To be clear for the Haskell newbies, he's talking about an implementation of the protobuf library, not Haskell. You can fairly easily lift from Template Haskell types into IO in GHC (not sure about TH in other compilers).


F# type providers sound like they're for this sort of thing. I expect Scala has a similar macro facility. Nemerle can probably do it too.


I don't want my language to be that complicated. "Powerful" has nothing to do with it.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: