Hacker News new | ask | show | jobs
by DoctorZeus 3908 days ago
The #run directive addresses some major pain points for me. Is there anything analogous in other languages?
4 comments

Yeah, similar constructs exist in D and Nim.

I don't know well enough how they compare to give any thorough analysis, though.

I don't know what Nim do but AFAIK in D you're (voluntarily) limited in what you can do at compile time because in effect with Jai compiling a program is running it, so this can have security implications..
In theory a good optimizing compiler should see that some code doesn't depend on anything external and do it, but I'm not sure to what extent they do. GCC with higher optimization settings does do some pretty crazy stuff, so I would expect it to figure out something like in the example code pretty easily.
All Lisps have macros, which are the same only more powerful (as they're allowed to transform code).
Yes, constexpr in C++.