6 ms·
> Python is both expressive and easy to learn; it is widely recognized as the easiest to learn widely-used programming language. Adding macros seems like a goo
by blackbear_ 6y ago
> Python is both expressive and easy to learn; it is widely recognized as the easiest to learn widely-used programming language.
Adding macros seems like a good way to destroy this reputation.
I am not convinced they are needed, and the examples provided leave me quite indifferent. But I haven't been enlightened by LISP yet so perhaps it's just me.
In particular,
> Many domains see repeated patterns that are difficult or impossible to express as a library. Macros can allow those patterns to be expressed in a more concise and less error prone way.
On the contrary, I believe such generic multi-domain libraries would be a hot mess to maintain. These abstractions would be way too high level, and undoubtedly different fields have significant, if small, different requirements.
- kwhitefoot 6y ago> easy to learn Used to be easy to learn but now it's just easy to get started.
- phonebucket 6y ago> Used to be easy to learn but now it's just easy to get started. What about it has got harder to learn? To do something technical involves knowing some technical library, but I believe that was always the case.
- teataster 6y agoAs the language keeps growing, it gets harder. If my code gets illuminated by constellations of stars and double stars or all my functions are decorated, most of my colleagues start giving me bad looks. In my humble opinion they are on the right. That's not what they signed for when they became Python fans.
- SuaveSteve 6y agoWe also didn't sign up to perform dark magic in order to publish our applications to desktop.
- Voloskaya 6y ago> , I believe such generic multi-domain libraries would be a hot mess to maintain. I think you (or I) understood it backwards. They see macro as a way to avoid multi-domain mess. Each domain could develop its own macro without having to worry about other domains, while in the base language everyone has to be considered.
- Daishiman 6y agoIn practice I have never observed a single domain in which Python's language constructs are terribly insufficient.
- Voloskaya 6y agoI don't think the bar is at "terribly insufficient" to be honest.
- Daishiman 6y agoPython has one of the best ORMs, the best web dev framework, the best REST framework, the best numeric processing library, the best machine learning libraries, and just all around excellent libraries for any domain you could possibly imagine. I have never thought, gee I wish I had macros. I have thought a hundred times more about multi line lambdas, and even so the number of situations where they would make my life easier bs being a source of confusion is very, very small. It's an essentially finished language at this point. The library warts are not worth it given the amount of language machinery you'd have to invent.
- uryga 6y agoi actually think both Django and Tensorflow would benefit from macros. in both cases you spend a lot of time writing what's really a DSL embedded into Python (defining models using a magic metaclass thingy / defining computation graphs, basically writing ASTs by hand). --- for another example, consider Foo = namedtuple('Foo', ['a', 'b']) where the namedtuple function actually has to hack around the fact that it's not a macro: https://github.com/python/cpython/blob/644e94272a89196801825cb69a56377bf62d256a/Lib/collections/__init__.py#L498 https://github.com/python/cpython/blob/644e94272a89196801825... tldr: Foo needs to have __module__ = 'yourmodule' __qualname__ = 'yourmodule.Foo' or else stuff like Pickle won't work right. so namedtuple has to reach into the caller's stackframe to see what module it was called from! this wouldn't be an issue if it was a macro and just expanded to a class definition.