How to tell if implementing your Python code is a good idea | Opensource.com

How to tell if implementing your Python code is a good idea

This is part of a special series about the Zen of Python focusing on the 17th and 18th principles: hard vs. easy.

Brick wall between two people, a developer and an operations manager
x

Subscribe now

Get the highlights in your inbox every week.

Subscribe today.

A language does not exist in the abstract. Every single language feature has to be implemented in code. It is easy to promise some features, but the implementation can get hairy. Hairy implementation means more potential for bugs, and, even worse, a maintenance burden for the ages.

The Zen of Python has answers for this conundrum.

If the implementation is hard to explain, it's a bad idea.

The most important thing about programming languages is predictability. Sometimes we explain the semantics of a certain construct in terms of abstract programming models, which do not correspond exactly to the implementation. However, the best of all explanations just explains the implementation.

If the implementation is hard to explain, it means the avenue is impossible.

If the implementation is easy to explain, it may be a good idea.

Just because something is easy does not mean it is worthwhile. However, once it is explained, it is much easier to judge whether it is a good idea.

This is why the second half of this principle intentionally equivocates: nothing is certain to be a good idea, but it always allows people to have that discussion.

Two animated computers waving one missing an arm

This is part of a special series about the Zen of Python focusing on the 12th, 13th, and 14th principles: the roles of ambiguity and obviousness.
Brick wall between two people, a developer and an operations manager

This is part of a special series about the Zen of Python focusing on the seventh, eighth, and ninth principles: readability, special cases, and practicality.
Digital creative of a browser on the internet

This is part of a special series about the Zen of Python focusing on the fifth and sixth principles: flatness and sparseness.

Topics

About the author

Moshe sitting down, head slightly to the side. His t-shirt has Guardians of the Galaxy silhoutes against a background of sound visualization bars.
Moshe Zadka - Moshe has been involved in the Linux community since 1998, helping in Linux "installation parties". He has been programming Python since 1999, and has contributed to the core Python interpreter. Moshe has been a DevOps/SRE since before those terms existed, caring deeply about software reliability, build reproducibility and other such things. He has worked in companies as small as three people and as big as tens of thousands -- usually some place around where software meets system administration...