Computer Things

Subscribe
Archives
  Back to the email
Sam Atman
Jun. 28, 2025, evening

The bug in Replacer illustrates Python's inferiority, not a weakness in dynamic languages. Python has its virtues, but is a bundle of weirdness and special cases, quite complex as a whole, and that makes this kind of thing fragile.

In Lua, it would work correctly. Even nil would be handled just fine, because it would become the empty table: it cannot be directly used to index a table, but literally anything else can be. Your example closely resembles a standard tactic to provide a function with memorization, although this is hard to make fully generic since Lua does not constrain the number of arguments, nor that of returned values.

This kind of 'hyperprogramming' (good name) is commonly seen in Smalltalk, Scheme, and the more rarified Lua circles, but seldom elsewhere. What those three have in common is a minimal and principled data model: objects, cons cells, and tables, respectively.

Python's is neither minimal nor principled: taking advantage of the dynamicism is difficult, because there are tonnes of types floating around and getting in each other's way. We just don't get to know what they are until it's too late.

Reply Report
Powered by Buttondown, the easiest way to start and grow your newsletter.