What does "Complex is better than complicated" mean?

Question:

In “The Zen of Python”, by Tim Peters, the sentence “Complex is better than complicated” confused me. Can anyone give a more detailed explanation or an example?

Asked By: flycondor

||

Answers:

Complex: Does a lot. Usually unavoidable.

Complicated: Difficult to understand.

I like this quote (source):

A complex person is like an iPod. That
is to say that they are consistent,
straightforward and ‘user friendly’
while also being rather sophisticated.
Unlike the complicated person,
interacting with a complex person does
not require special knowledge of their
complicated ways-because their ways
are not complicated. When mistakes are
made, they tend to be very forgiving
because they understand that people
are imperfect. In short, they are
mature, sensible human beings.

and this one (source):

An Airbus A380 is complicated. A
jellyfish is complex. The Paris Metro
network is complicated. How people use
it is complex. Your skeleton is
complicated. You are complex. A
building is complicated. A city is
complex.

Some more articles on this:

Answered By: moinudin

i haven’t read this book.

complex is in my opinion a solution that might be not easy to understand but is writen in simple and logic code.

complicated is a solution that might be simple (or complex) but is written in code which is not easy to understand because there are no patterns or logic in it and no proper metaphors and naming.

Answered By: Christian

although complex and complicated sound alike, they do not mean the same in this context.

The Zen therefore says: It is okay to build very complex applications, as long as the need for it is reasonable.

To give an example:

counter = 0
while counter < 5:
   print counter
   counter += 1

The code is very easy to understand. It is not complex. However, it is complicated. You do not need to manually perform most of the steps above.

for i in xrange(5):
   print i

This code is more complex than the above example. But: knowing the documentation of ´xrange´ you can understand it by a single glance. Many steps are hidden behind an easy-to-use-interface.

As processes grow bigger, the gap between complicated and complex gets wider and wider.

A general rule of thumb is to follow the other principles of the Zen of Python:

If it is hard to explain, it is not a good idea.

If it’s easy to explain, it might be a good idea.

Answered By: EinLama

Complicated systems are highly coupled and therefore fragile.

Complex systems are made of simple parts operating together to create complex emergent behavior. While the emergent behaviors may still be a challenge, the individual parts can be isolated, studied, and debugged. Individual parts can be removed and reused.

I comment more on this topic and provide examples on my blog

Answered By: Daniel

For “complicated”, the difficult thing is on the surface. (You description is complicated.)

For “complex”, the difficult thing is under the table. (A car is complex.)

Just as shown by EinLama’s examples.

Answered By: Charles Jie

According to Pro Python third edition:

For the sake of this guideline, most situations tend to take the following view of
the two terms:
• Complex: Made up of many interconnected parts
• Complicated: So complex as to be difficult to understand
So in the face of an interface that requires a large number of things to keep track of,
it’s even more important to retain as much simplicity as possible. This can take the form
of consolidating methods onto a smaller number of objects, perhaps grouping objects
into more logical arrangements or even simply making sure to use names that make
sense without having to dig into the code to understand them.

So you as the book said, you need to make your code and file more organized and use most readble names to define variables/funtions as you can.

Actually, the best answer accepted is more likely to describe the upper rule:

Simple is better than complex.

Here is the snippet example of “Simple is better than complex.” from the book:

if value is not None and value != ":
if value:

Obviously, the second line is simpler than first one and more easy to munipulate, and more likely with the best answer example code.

Answered By: Berb

Complicated: Need a lot of brain juice (your internal CPU) to solve. But once you solved it, you know it is right. Solving a math problem is complicated. Once done, easy for you to do it a second time. But difficult again for your friend.

Complex: Need a lot of intuition to solve (your accumulated experience). And once you choose a way, you cannot be sure this was the best one. Human relations are complex. Doing it again a second time will still be challenging for you. But someone following your path (reading your code…) can follow you easily.

Algorithms aim to solve complicated problems.

Machine learning aims to find answers to complex problems.

Algorithms are predictable. Deep Learning raises explainability questions on why the computer has decided to select that specific answer.

So now it is your time to answer: was your question complex or complicated?

Answered By: Benoît Galy
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.