4 ms·
So how many programming languages besides LISP are powerful enough to support turning Protocol Buffers into code during compilation? And is this the ultimate mu
by zuzun 12y ago
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?
- logicchains 12y agoIt 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.
- pjmlp 12y agoD, Rust, Nim(rod), Template Haskell, OCaml, C++...
- mseepgood 12y agoI don't think these can open and read .proto files during compilation.
- pcwalton 12y agoRust can.
- tuxychandru 12y agoAre you referring to compiler plugins like the one providing regex! macro or is it something else?
- wycats 12y agoYes, 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 https://github.com/docopt/docopt.rs
- pjmlp 12y agoD 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.
- thesz 12y agoTemplate Haskell code can runIO I/O actions, including reading files.
- jeremyjh 12y agoHaskell can, but there is not an implementation that does this.
- hawkice 12y agoTo 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).
- ben0x539 12y agoF# 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.
- NateDad 12y agoI don't want my language to be that complicated. "Powerful" has nothing to do with it.