Why you always had trouble understanding metaclasses

The problem of using bad names isn't just lost brainpower; it can also be confusion

Antonis Christofides

Clean Code Documentation Meta Classes Programming

See in schedule

"Smart people sometimes like to show off their smarts by demonstrating their mental juggling abilities. After all, if you can reliably remember that r is the lower-cased version of the url with the host and scheme removed, then you must clearly be very smart.

One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king."

— Robert C. Martin, "Clean Code", p.25

Robert C. Martin says it’s hard to mentally translate one name (e.g. “r”) to another, and you can avoid it by using a better name (e.g. “urlPath”). But the problem is not just lost brainpower; it can also be misunderstanding. I’ve seen experienced Python programmers trying to teach Python “metaclasses”—one of the most difficult concepts of Python—by explaining that a metaclass is the class of a class—which it isn’t.

In fact, bad terminology can be far more damaging than just confusing people. In April 2021, the European Commission published a proposal for an Artificial Intelligence Act, which they proudly advertise as the “first ever legal framework on AI”. It has provisions such as prohibiting "an AI system that deploys subliminal techniques beyond a person’s consciousness in order to materially distort a person’s behaviour in a manner that causes or is likely to cause that person or another person physical or psychological harm.” What do they mean with "AI system"? Well, more or less... statistics.

None of this would happen if we didn't use misleading terms such as "artificial intelligence".

Type: Talk (30 mins); Python level: Beginner; Domain level: Beginner


Antonis Christofides

Self-employed

I’m an experienced IT professional focusing on science and engineering. My experience is mostly in hydrology. The last few years I have been working on Enhydris (a web-accessible database of meteorological stations and their measurements, https://openmeteo.org/) and Aira (a web-based system that helps farmers improve irrigation, https://irmasys.eu/).

I author a newletter on science and software, available online at https://antonischristofides.substack.com/