Hacker News new | ask | show | jobs
by skohan 1865 days ago
I think what's novel about Zig's approach is that the metaprogramming is just normal code which happens to be executed at compile-time.

I have found that when any project gets to a certain size, it's almost inevitable that metaprogramming will be required, unless you want to make everything super dynamic and sacrifice performance. The idea of being able to do metaprogramming in the language I used to write the program itself is an interesting one.

2 comments

I don't know if Kelley would agree with my characterization, but I don't see comptime as metaprogramming. Instead it opens the very interesting possibility of having types as values, as long as those values are resolvable at compile time. This lets you do things that feel like metaprogramming (e.g. making a generic container structure) but it seems a better conceptual fit to me that you're programming with types as values rather than generating code from a template or macro.
This is nothing novel. LISP macros is exactly that.