What a powerful thing metaprogramming is!
While editing a chapter of my book, I was introducing the concept of metaprogramming using Python’s type
function. It occurred to me that I had already introduced metaprogramming several chapters earlier when introducing decorators.
Defining a function within another function is as important to my programming as bread is to French cuisine. I began thinking of all those cultures without wheat; all those languages without, or with newly added support for, metaprogramming. I have never done serious development in a language without anonymous functions, closures, and reflection.
It was exciting to think of a coming generation of programmers who are in my shoes (I started programming relatively late in life), who would be inherently comfortable with passing functions. It was exciting to realize where languages are going, keeping static typing but removing the explicit part. It was exciting to think of how flexible, expressive, and powerful languages have become.
It also allowed me to think of less flexible languages and what they’ve been able to achieve. I am lucky to be programming now, but surely each programmer before me felt the same about those before them. More will feel the same after and about me. Really my luck is to be part of what is still such a new and remarkable part of the human endeavor.
All of this feeling from type
and decorators. What a powerful thing metaprogramming is!
I’m already thinking that sometimes Python gives you too much freedom to do whatever, rather than forcing some order into things. So don’t forget the warning in your book: With great power comes great responsibility :)
Hah! Yes I initially didn’t like Python for teaching people programming because it can be really unstructured. I thought something like C# or Java more constructive. Not sure I still think this but very possibly.