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

> ...has been standard advice since decades before Clojure.

Yes, but we're in a thread dedicated to Clojure ;)

> "Macros make things horribly complicated" is nonsense, or no skilled programmer would use them.

Which is what happens, really, and when used it's in a very limited fashion. For example, for quite popular projects inside the Clojure community: Leiningen used one macro[1] and Compojure two[2].

A properly done (and properly used) macro might not make things complicated, but this leads me to the next paragraph.

> ease of debugging is an issue quite apart from anything to do with macros.

It's usually hard, but macros make it HORRIBLE since you can easily lost track of the generated code. Like if translating from Clojure to Java Stack Traces wasn't hard enough...

Whenever you use a macro, the stack traces you receive from the code using it might not like like what you expect at all. Macros are bad because they mutate your code. You usually have to expand the macro and debug there instead of just looking at your damn code.

The big problem is not macros, but code which uses macros.

[1] https://github.com/technomancy/leiningen/search?q=defmacro&r... [2]https://github.com/weavejester/compojure/search?q=defmacro&r...



This does not match my experience. I write macros to make my code shorter when I notice a repeating pattern. To see what the macros do, I use macroexpand. Is debugging a problem? Well, I understand the macroexpansions so I can read them when I need to—so no, it's not that big a problem. You're not the first Clojure person I've heard talk this way about macros, and I don't understand why anyone would be so eager to deprecate such a powerful technique. Especially since it actually works (and works well) in Lisps, and not nearly as well elsewhere.

Also, these comments seem odd:

A properly done (and properly used) macro

The big problem is not macros, but code which uses macros.

The macros I know are effectively impossible to misuse. They tell you how they're supposed to be used and you just do it. There's not a lot of room to go wrong! Can you give an example of a macro which is hard to use properly?


> I write macros to make my code shorter when I notice a repeating pattern.

I do that using functions :)




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

Search: