Re:Bad programming ideas that only become apparent after years
by bsder on Sunday December 27, 2020 @09:04PM
(#25556052)
> Re macros: I think this is entirely a cultural thing.
I suspect there is also a generational divide.
Lisp is such an old language that I often wondered if it has so many macros because they didn't have the equivalent of "defun-inline". ie. That far too many usages of macros in the Lisps were for performance rather than for abstraction.
In modern languages, though, macros are really the only way to get at something like the AST of a language and act like the original developers of the language. I personally approve of this--the Go "Me, but not for thee" attitude of the language developers pisses me off.
However, given such power, usage of a macro should set off your "I'm using a macro. This language ecosystem is deficient somehow". And that should give you pause and you should ask "Am I really adding something to this language or am I just carrying over my habits from other languages?"
Finally, using a macro merely for "abstraction" should set off gigantic klaxon warning bells. A macro has to pass a really high bar if you could actually do the task with just functions and a little extra bit of keyboard typing.
I suspect there is also a generational divide.
Lisp is such an old language that I often wondered if it has so many macros because they didn't have the equivalent of "defun-inline". ie. That far too many usages of macros in the Lisps were for performance rather than for abstraction.
In modern languages, though, macros are really the only way to get at something like the AST of a language and act like the original developers of the language. I personally approve of this--the Go "Me, but not for thee" attitude of the language developers pisses me off.
However, given such power, usage of a macro should set off your "I'm using a macro. This language ecosystem is deficient somehow". And that should give you pause and you should ask "Am I really adding something to this language or am I just carrying over my habits from other languages?"
Finally, using a macro merely for "abstraction" should set off gigantic klaxon warning bells. A macro has to pass a really high bar if you could actually do the task with just functions and a little extra bit of keyboard typing.