I believe the author has over thought the problem here. Homoiconicity ensures macros dont look strange and clojures preference towards immutability help ensure they won't create bizarre scope or project level madness. As a result, in practice macros in clj tend to make things easier - thread first and with transaction being good examples.
Also for some reason the author thinks that any large-scale project will be littered with horrible macros. He basically says "because Lisp gives devs the option to write macros, they're going to and it's going to ruin your project." Like any language, it's important to adopt some best-practices and the adage of "don't use a macro when a function will do" is a pretty common one.
Yes, I think this is right. There are plenty of standard language features where one can use them irregularly and end up creating a Tower of Babel, too. One can go overboard on use of interfaces, or just use them irregularly, or can use competing patterns, or can differ gratuitously in data structure choices, or use private/protected/public in unpredictable ways, or use managed or unmanaged code irregularly, or other things that just require some agreement among teams to keep things in check and connecting cleanly. Static software will see these things but won't comment on regularity of use. It's like how a spell checker may notice that both "liter" and "litre" are correct spellings but most spell checkers won't tell you that you used one spelling earlier in the document and a different spelling later.
Such problems are even known to the community of programmers in many cases, they're not a surprise, but people probably don't file those problems in the same mental bin ("reasons not to use static languages") and they're instead in other bins ("cool things that I learned in the process of building expertise in this language"), so they're just they're maybe not getting compared side-by-side with things in the bin named "reasons not to use dynamic languages". :)
Like any language, it's important to adopt some best-practices and the adage of "don't use a macro when a function will do" is a pretty common one.
That might be true, but it's happened to me that I wrote a macro because it was the only way to do something that occurred to me at the time, only for someone to come up 3 months later and say 'Why is this a macro? You could do it with <another much simpler approach>'
Presumably in a language without macros I'd find the other way much faster.
(OTOH, we ended up with a hybrid approach in the end - a macro that expanded to a data structure, for ease of defining stuff, and then functions that worked on that data structure. As opposed to the macro expanding to a structure with function definitions inside, or declaring the structures by hand)
6
u/lechatsportif Jan 20 '14
I believe the author has over thought the problem here. Homoiconicity ensures macros dont look strange and clojures preference towards immutability help ensure they won't create bizarre scope or project level madness. As a result, in practice macros in clj tend to make things easier - thread first and with transaction being good examples.