Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I think you mean within reasonable programs that's not a metric that matters because most programs solve problems that don't need much autogeneration to be solved. For problems that do need autogeneration macros are one of the strongest ways.

No, I meant languages (as in programming languages), not programs.

> A good way to become convinced of the power of macros is to try and write a web app in Arc to generate lots of HTML.

I'm already convinced macros are powerful. The problem is that they're also extremely error prone, and can be extremely difficult to debug when errors inevitably occur.

This isn't controversial. Land Of Lisp[1] has a section titled "Macros: Dangers and Alternatives". The elisp docs[2] contain a section on "Common Problems Using Macros". Paul Graham's On Lisp[3] contains a chapter on variable capture which consists mostly of sections on avoiding variable capture problems, followed by a chapter called Other Macro Pitfalls.

These are the people who like Lisp writing these things. The controversial thing I'm saying is that I don't think the power/danger tradeoff is worth it. That's pretty subjective and it's reasonable to disagree with that, but you can't reasonably disagree that macros are error prone when even the people writing Lisp variants are saying they are error-prone.

The best HTML generation I've experienced is with Ruby templates. They're not as terse as Lisp macros, but I don't end up having to debug them very often, and when I do end up debugging them, the bugs are usually trivial to find and fix.

> Autogeneration can be done with macros and is simpler with macros.

I have never spent hours debugging an IDE autocomplete. I have spent many hours debugging macros.

You're only looking at the positives of macros and ignoring everything I've said about the negatives.

[1] https://www.oreilly.com/library/view/land-of-lisp/9781593272...

[2] https://www.gnu.org/software/emacs/manual/html_node/elisp/Pr...

[3] https://redirect.cs.umbc.edu/courses/331/fall10/resources/li...



Thanks for sharing your experience with Ruby templates and for the links.

> I don't think the power/danger tradeoff is worth it.

The power/danger tradeoff might not be worth it for the overwhelming majority of programs. For some kinds of programs I don't see how this power can be got with anything less powerful than macros.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: