4 ms·
> The key problem has been that the resulting programs are fantastically hard to understand. One of the things I think Dijkstra got right in "Goto Considered Ha
by majewsky 4y ago
> The key problem has been that the resulting programs are fantastically hard to understand. One of the things I think Dijkstra got right in "Goto Considered Harmful" is that humans can reason about programs better when there's a strong correspondence between the textual structure of the code and its execution structure at runtime.
When I briefly worked on a Ruby on Rails app in 2015, my first ticket was to investigate a crash that had been reported. I quickly reproduced the issue and got a stacktrace that ended in a function call to "is_readable", so I said: "No problem, I'm just going to grep for that identifier to find the definition." Cue two hours of utter frustration until I learn that you can use `.source_location` on a function to get a file and line where it is defined, which pointed me to a pile of metaprogramming held together by strings and class_eval. To no one's surprise, I fully support the statement quoted above.
- ok_dad 4y agoYes, look at literally any complex Python library and there's generally going to be an unreadable mess of dunderscore properties and ClassFactory stuff. I've seen Python libraries that call a SQL database query and then build Python objects and code from that! What a nightmare.
- andreareina 4y agoNamedtuples were (are?) constructed with eval under the hood
- pmontra 4y agoMany years ago I worked on a Rails project where the two previous developers were particularly creative with metaprogramming. That cost a lot of time and extra money to my customer because it was really hard to figure out all the tricks they used. Instead I write Rails projects in the simplest possible way I can figure out. It works and everybody else and I will be able to understand it quickly next year. If it makes me look dull, I don't care.