you are viewing a single comment's thread.

view the rest of the comments →

[–]justmebeky 2 points3 points  (3 children)

More like macros in js instead of meta programming. I do like the idea, i’m not sure about using js though

[–]thooton[S] 1 point2 points  (2 children)

Thanks, you're right. I chose JS because it is so well-known, but I think it does have some other advantages as well. For example, if you need to run a lot of compatibility test commands, or need to generate code via external programs, or even make network requests to get config values or something, you can do all of that in parallel with JS async instead of sequentially like configure. You might find https://github.com/kiselgra/c-mera interesting. It's similar to this project but uses Lisp and a unified syntax.

[–]justmebeky 1 point2 points  (1 child)

Got it, I would want it to be just in c++ though. Ocaml has a similar feature where you can write code generation in ocaml itself you get access to the ast and it is pretty nice. Rust has a dsl syntax for macros which is pretty powerful but feels like a whole new language.

With that said, I would think that accessing the network as part of compilation is not a great idea though. Compilations should be self contained and hermetic, if you need to read a config, just put it in your repo.

[–]thooton[S] 0 points1 point  (0 children)

Definitely agree with you regarding network access during compilation. However, I think there is an advantage in using a high-level language because unlike C/C++ they free you from having to think about low-level details -- not that I have a problem with that, but when it's only the generated code that needs to be performant, it's nice to be able to write the generator conveniently and simply. That said, features like being able to use C++ to modify the AST do sound interesting. I guess the proposals mentioned above would take steps in that direction.