5 ms·
Re macros: I think this is entirely a cultural thing. For example, in lisp, macros are used ubiquitously, and I think if anyone was going to criticize macros a
by habitue 6y ago
Re macros: I think this is entirely a cultural thing.
For example, in lisp, macros are used ubiquitously, and I think if anyone was going to criticize macros as a language feature it would be based on what they've seen in lisp (or C, but let's ignore that for the moment).
Meanwhile, in python, there are extensive metaprogramming facilities that could easily be used to make code very hard to understand (Even if you never use eval, you have decorators, metaclasses and descriptors etc).
I think the difference is cultural. Python has a norm of resorting to metaprogramming as a last resort, and largely in libraries and frameworks, not in application code. Certainly there's no compiler forcing people not to use all of the flexibility available in python at every turn. Even compared to a similar language like Ruby, python metaprogramming use is generally pretty restrained.
(My understanding of the implied context is that Walter Bright, the creator of D, is likely looking at macro usage in lisp, and inferring that macros are a mistake in a language like Rust. I know Walter is on here pretty often so if I'm guessing wrong here feel free to correct me)
- ashkankiani 6y agoCalling it cultural doesn't make sense to me, considering every difference you pointed out was based on the language's support for macros. C macros are a text generation hack from 40 years ago, lisp macros are a first class citizen, python metaprogramming is supported first class but hard to debug because of python's debugging tools. It's easy to see that the problem isn't "cultural," but the language's design and tooling.
- njharman 6y agoYes. This list seems closer to "problems with c/c++"
- bsder 6y ago> 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.