News for hackers. Stuff that matters.
Re:Is Zig's New Writer Unsafe? by adgjlsfhk1 on Saturday September 20, 2025 @11:51AM (#45314386)
To be clear, the problem with C isn't macros, but text based macros. Syntax based macros are really good (as shown by Lisp and friends)
Re:Is Zig's New Writer Unsafe? by jeremyjh on Saturday September 20, 2025 @11:57AM (#45314427)
To be clear, we all know GP is talking about C macros.
Re:Is Zig's New Writer Unsafe? by ManBeardPc on Saturday September 20, 2025 @03:44PM (#45316686)
Not only being text based but also having another separate language is problematic. Rust also has powerful declarative macros but it is it’s own language. Procedural macros and crabtime are imho a bit better for more complex cases as you write Rust.
Re:Is Zig's New Writer Unsafe? by pron on Saturday September 20, 2025 @05:45PM (#45317853)
AST macros are very powerful. As to them being "good", that's debatable. They have advantages but also disadvantages. For one, they operate on syntax, so they're a separate metalanguage and not so pleasant to debug. For another, they are referentially opaque (i.e. when passed different expressions with the same meaning, they can produce different results), which makes them powerful but also mysterious.

What's interesting about Zig's comptime is that while it's strictly less powerful than AST macros, it can do a lot of what macros can do while not being a metalanguage - just Zig.