logoalt Hacker News

Quitschquat04/23/20256 repliesview on HN

It would be cool to have the entire language and runtime available at compile-time like in Lisp


Replies

MrRadar04/23/2025

The D language basically does that. You can write D programs that evaluate D code at compile time to generate strings of new D code which you can then basically compile-time eval into your code as needed. Combined with the extremely powerful compile-time reflection capabilities of D it's the closest thing I've seen to Lisp metaprogramming outside of that family of languages and it's easier to read than Rust macros or C++ template metaprogramming.

show 3 replies
kazinator04/23/2025

It would be cool, except for the entire language that is available at compile-time being C++, and thus entirely unsuitable for manipulating C++ programs.

show 1 reply
klipt04/23/2025

Circle C++ does that

show 1 reply
yuppiemephisto04/23/2025

Maybe too far afield, but: https://leanprover-community.github.io/lean4-metaprogramming...

Gives what you wished for. It's functional, though (among other things). Unlike most lisps, (dependently) typed. But hey, available at compile-time.

chrisrodrigue04/23/2025

...isn't that what templates were made for? Template metaprogramming in C++ is Turing-complete.

show 2 replies
jjmarr04/23/2025

This already exists with macros, templates, and compiler extensions, if you want completely unusable/unreadable code that takes forever to build.

show 1 reply