Python Is Engineering, Not Art


When Python first emerged on the software scene in the early 1990s, it spawned what
is now something of a classic conflict between its proponents and those of another
popular scripting language, Perl. Personally, I think the debate is tired and unwarranted
today—developers are smart enough to draw their own conclusions. Still, this is one
of the most common topics I’m asked about on the training road, so it seems fitting to
say a few words about it here.
The short story is this: you can do everything in Python that you can in Perl, but you can
read your code after you do it. That’s it—their domains largely overlap, but Python is
more focused on producing readable code. For many, the enhanced readability of Python

translates to better code reusability and maintainability, making Python a better
choice for programs that will not be written once and thrown away. Perl code is easy
to write, but difficult to read. Given that most software has a lifespan much longer than
its initial creation, many see Python as a more effective tool.
The somewhat longer story reflects the backgrounds of the designers of the two languages
and underscores some of the main reasons people choose to use Python. Python’s
creator is a mathematician by training; as such, he produced a language with a
high degree of uniformity—its syntax and toolset are remarkably coherent. Moreover,
like math, Python’s design is orthogonal—most of the language follows from a small
set of core concepts. For instance, once one grasps Python’s flavor of polymorphism,
the rest is largely just details.
By contrast, the creator of the Perl language is a linguist, and its design reflects this
heritage. There are many ways to accomplish the same tasks in Perl, and language
constructs interact in context-sensitive and sometimes quite subtle ways—much like
natural language. As the well-known Perl motto states, “There’s more than one way to
do it.” Given this design, both the Perl language and its user community have historically
encouraged freedom of expression when writing code. One person’s Perl code can
be radically different from another’s. In fact, writing unique, tricky code is often a
source of pride among Perl users.

But as anyone who has done any substantial code maintenance should be able to attest,
freedom of expression is great for art, but lousy for engineering. In engineering, we need
a minimal feature set and predictability. In engineering, freedom of expression can lead
to maintenance nightmares. As more than one Perl user has confided to me, the result
of too much freedom is often code that is much easier to rewrite from scratch than to
modify.
Consider this: when people create a painting or a sculpture, they do so for themselves
for purely aesthetic purposes. The possibility of someone else having to change that
painting or sculpture later does not enter into it. This is a critical difference between
art and engineering. When people write software, they are not writing it for themselves.
In fact, they are not even writing primarily for the computer. Rather, good programmers
know that code is written for the next human being who has to read it in order to
maintain or reuse it. If that person cannot understand the code, it’s all but useless in a
realistic development scenario.
This is where many people find that Python most clearly differentiates itself from
scripting languages like Perl. Because Python’s syntax model almost forces users to
write readable code, Python programs lend themselves more directly to the full software
development cycle. And because Python emphasizes ideas such as limited interactions,
code uniformity and regularity, and feature consistency, it more directly fosters code
that can be used long after it is first written.
In the long run, Python’s focus on code quality in itself boosts programmer productivity,
as well as programmer satisfaction. Python programmers can be creative, too, of
course, and as we’ll see, the language does offer multiple solutions for some tasks. At
its core, though, Python encourages good engineering in ways that other scripting languages
often do not.


Comments

Popular posts from this blog

What happened to the blog ?

Why I love to be a programmer ?