Hacker News new | ask | show | jobs
by gwerbin 5 days ago
It's interesting seeing this discussion in Rust because it's the same discussion that's been happening around macros in Scheme for decades. It's one of those things where there probably is no universal correct answer, so might as well allow both in your language and let the programmer decide what's best for their case.
2 comments

I think D got it right by not supporting any macro, and become very fast in compilation while being consistent in the syntax, easier to maintain and debug. This remind me of a famous quote, "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

D also show the programming world that you don't need to go macro, or Ruby styled 'macro' that can create complicated franskeintein codes in order to achieve good metaprogramming capability [1].

[1] Metaprogramming is less fun in D (88 comments):

https://news.ycombinator.com/item?id=14165198

My rule of thumb has always been that, macros are great for general things but very bad for domain-specific things.

A macro like (logged-fn) that defines a function which logs the arguments passed, is wonderful.

But if you see a macro like (validate-report), something very wrong happened.