Swizec Teller - a geek with a hatswizec.com

    Complex vs. complicated

    Friend, would you rather work with a complex system or a complicated system? 🤔

    On Twitter, everyone said "complex". They're wrong.

    Swizec Teller published SeniorMindset.com avatarSwizec Teller published SeniorMindset.com@Swizec
    Would you rather work with a complex system or a complicated system?

    A car engine is complicated (lots of moving parts), a rocket is complex (tightly balanced explosion), which do you think is easier and cheaper to build?

    Complex systems

    From Wikipedia:

    Complexity, the behaviour of a system whose components interact in multiple ways so possible interactions are difficult to describe

    /../ many parts where those parts interact with each other in multiple ways, culminating in a higher order of emergence greater than the sum of its parts

    A complex system is like weather. Local rules are easy to follow, global behavior is emergent and complex. Any action may lead to unpredictable results down the line.

    Take Conway's Game of Life for example. Simple rules, complex results.

    Gosper's glider gun in Conway's game of life

    The game follows 3 rules:

    1. Any live cell with two or three live neighbours survives.
    2. Any dead cell with three live neighbours becomes a live cell.
    3. All other live cells die in the next generation. Similarly, all other dead cells stay dead.

    Simple, right?

    It is, but you can implement A Turing Machine in Conway's Game of Life, if you choose the right starting conditions. That's a universal computer built with 3 basic rules. 🤯

    A Turing Machine in Conway's Game of Life
    A Turing Machine in Conway's Game of Life

    This is what complexity gets you – mindblowing results from simple rules. One of Conway's original design goals was that

    There should exist small initial patterns with chaotic, unpredictable outcomes.

    Good luck debugging any of that.

    PS: when you add probabilistic behavior, your complex system becomes a chaotic system

    Complicated systems

    A complicated system is like a Rube Goldberg machine.

    The self-operating napkin

    Complicated systems have lots of moving pieces, but they're all connected in predictable ways. Actions lead to predictable outcomes.

    You can debug a complicated system by tracing a path from action to result. Function A calls B, which calls C, which does D, which produces result E.

    A → E

    The problem is that steps B, C, and D may break. The more steps there are, the likelier something goes wrong, the harder your code is to understand.

    Remove steps until there's nothing left to remove.

    Complex + complicated systems

    Ideally your system is neither complex nor complicated. Unfortunately it's going to be both.

    Complicated code happens when you don't understand the requirements yet. When you add exception on top of exception because the underlying rules aren't clear.

    Compare how complicated the solar system had to be to fit observed reality to the model that earth is at the middle. Change that assumption and wow 😍

    Heliocentric vs. Geocentric orbits

    Complicated code is a good sign your mental model is wrong. Step back and rethink your approach.

    Complex systems arise when minimally complicated (simple?) systems interact. We use this to break down large problems into smaller pieces. Makes them easier to think about.

    Every large system is complex system

    You end up with a series of internally "complicated" modules that talk to other modules through an API. The behavior that emerges is ruled by complexity.

    Make those interactions explicit and you'll be fine. Use observables and spooky events-at-a-distance and welcome to hell. 😈

    Cheers,
    ~Swizec

    PS: working on your code as a team is always a complex system, because humans

    Did you enjoy this article?

    Published on August 3rd, 2021 in Engineering, Opinions,

    Learned something new?
    Want to become an expert?

    Here's how it works 👇

    Leave your email and I'll send you thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

    Join Swizec's Newsletter

    And get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.

    "Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"

    ~ Ashish Kumar

    Join 15,161+ engineers just like you already growing their careers with my emails, workshops, books, and courses.

    ⭐️⭐️⭐️⭐️✨
    4.5 stars average rating

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Want to brush up on modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️