3 ms·
> If macros are used responsibly, they can make a program more readable. (AST based) Macros can really be an asset in a statically typed language (like Rust or
by throw_m239339 6y ago
> If macros are used responsibly, they can make a program more readable.
(AST based) Macros can really be an asset in a statically typed language (like Rust or Crystal), they are crap in C since it's text substitution [1], but an interpreted language that already has a lot of meta programming capabilities doesn't really need macros. Python has problems, but you don't fix those with Macros on top of them. They will never be used responsibly.
1: With a better macro system C could have been a much better and secure language IMHO.
- rbanffy 6y agoMetaprogramming has a runtime cost that macros (even crappy C-like ones) don't. In the case of an interpreted language, this is an important feature. Having said that, I haven't seen metaprogramming being overused or abused much in Python.
- 10000truths 6y agoYou shouldn't be using Python in the first place if you're worried about the runtime cost of metaprogramming.
- rbanffy 6y agoIf macros offer the same benefit at no additional cost, why not?
- formerly_proven 6y agoMacros have decidedly nonzero cost. Look at the discussion from the core devs surrounding this; just the implementation is a major change for the parsing and AST modules with unclear performance implications. Introducing this much complexity to the language is far from "no cost" as well. I predict that if this PEP goes through, it will be a watershed moment for Python and the language will become an unrecognizable mess (more so than already) within a few years. If GvR was still in charge, I would be sure that this would be dismissed. Now, I am not so sure, and that troubles me.