Back to the notes

Python is becoming Pinyin

Reuven Lerner argues Python's syntax sugar is making it harder to explain what code actually does. He compares it to Pinyin romanisation: useful for getting started, obscuring the underlying structure.

A row of books photographed at table height
Tom Hermans / Unsplash Unsplash License

Reuven Lerner wrote about Python’s accumulating syntax sugar and compared it to Pinyin, the romanisation system for Mandarin Chinese. The metaphor lands. Pinyin lets you type Chinese characters without memorising thousands of strokes. But if you only know Pinyin, you cannot read street signs, restaurant menus, or historical texts. Python’s sugar, walrus operators and match statements and positional-only parameters, feels the same. You can write functional code without understanding what the interpreter is doing underneath. The problem is teaching. Lerner points out that explaining match requires explaining pattern matching, which requires explaining structural comparison, which bottoms out in concepts most beginners do not have yet. The same for the walrus operator: you need to understand assignment, expressions, and scope before := makes sense. Instead of reducing complexity, the sugar hides it. I see this in ML codebases. Someone uses a walrus operator in a list comprehension and saves one line. The next person who reads it takes three minutes to parse what the line does. Not because they are slow, but because the syntax is doing two things at once and the cognitive load is real. Python used to be the language you could explain in a weekend. Now it is the language with seventeen ways to unpack arguments and three ways to format strings. The Zen of Python says there should be one obvious way to do it. We are past that. I still think Python is the right choice for most ML work. But I wish the language had stopped adding features five years ago.


Source: Is Python Becoming Pinyin?

Back to all notes

Behind the notes

Vikrant
Sharma.

Artificial Intelligence Engineer intern at Voxon Photonics in Adelaide. Studying a Master of Information and Communications Technology at UniSC, with a focus on data, machine learning and security.

Meet the person behind the work