Skip to content

· 6 min read

From Reactors to Load Balancers: What Chemical Engineering Taught Me About Software

I quit a zinc coating plant after three months and taught myself software. My degree gave me a little MATLAB and something more useful: how to see a system.

I studied chemical engineering. After graduating, I worked three months in a zinc coating plant, quit, studied software for six months, and got hired by a five-person startup. Today I'm a full-stack engineer in London.

The degree taught me a little coding, in MATLAB. It also taught me something more useful: how to look at a system. Chemical engineers see a plant as a set of components, each designed on its own and then connected. I read software the same way. This post is how I got from one to the other, the two courses I failed on the way, and the four habits I still use every week.

Where I first met programming

It was the second term of my first year. Our programming course used MATLAB, and so did Numerical Methods later: we plotted functions and solved a lot of equations.

It came easily to me, much more than to most of my classmates, and I noticed. I remember thinking I should do something in this field. Then I did nothing about it for years, and went on studying to be a chemical engineer.

From a fail to an A

In the middle of my degree, I hit a wall and failed two core courses: Separation Processes, and Process Dynamics and Control.

I didn't drop them. I retook both and passed each with an A.

I don't tell this to sound tough. I tell it because it's the clearest evidence I have of how I work: when something fails, I go back to it until it doesn't.

Three months in a zinc coating plant

After graduating, I took a job as a chemical engineer in a zinc coating plant. My job was in the field, checking the production process. I wasn't part of the team that made the decisions, and I couldn't see a way to grow there.

I lasted three months. One of my professors had told our class that a chemical engineer can do anything in the world, and I'd always taken that seriously. The skills we learned weren't only for chemical plants. So I quit to do the work I'd wanted to do since my first year.

Six months of 12-hour days

For the next six months I studied software for about 12 hours a day, without taking a day off. I learned through courses, like one on the command line, and mostly by building small games: Snake, Tetris, Pacman, Helix Jump. Each one taught me something new, like a fixed-step game loop, grid collisions or a ghost's state machine.

Games were a good teacher because they're hard to fake. Either the ghosts chase you correctly or they don't.

Why a five-person startup hired a chemical engineer

My portfolio of finished games got me an interview at Sugar Technology, then a five-person startup. I told them how much I loved maths and programming, and they hired me.

I only learned the real reason later, from the founder. They'd seen that I finished every project I started, and that I was stubborn and consistent. Stubborn in the useful sense: I don't leave a problem half-solved. It's the same habit that got me through those retakes.

I stayed two and a half years, and the company grew to 25 people. I've kept studying since: a full-stack web development bootcamp, a course on GitHub Actions for CI, and an MSc in Computer Science to fill the gaps a chemical engineering degree leaves.

Every system is made of unit operations

In 1916, Arthur D. Little gave chemical engineering the idea of unit operations: every plant, however complex, is built from a small set of standard steps, like pumping, heating, mixing, reacting and separating. You design each unit on its own, then connect them with pipes.

Once you see a plant like that, you see it everywhere. A web app is built the same way:

Chemical plantWeb application
Pipes carry the flowThe network carries requests
Pumps and valves control the flowLoad balancers and rate limits control traffic
Reactors transform the materialServers transform the data
Tanks store itDatabases store it
Sensors measure itLogs and metrics measure it

That's how I approach a new system: name the units, understand each one, then follow the flow between them. Four habits from the degree do most of the work, and I'll show three of them on this site's own code.

Conservation: what goes in must come out

The first thing a chemical engineer learns is the mass balance: what goes in, minus what comes out, is what builds up inside. Nothing appears or disappears without a reason.

A memory leak is the same equation. Memory a program takes, minus memory it gives back, is what builds up. When a long-running app gets slower by the hour, I don't start with the code. I start with the balance: what keeps coming in that never goes out, like a cache with no limit or an event listener that's never removed.

Failure modes: what if the flow is missing, doubled or wrong?

Chemical plants are checked with a HAZOP study: for every section of the plant, you ask what happens with no flow, more flow, less flow or reverse flow.

I ask the same of every input. The API behind /stats accepts reports only from this site's own pages, rejects anything that doesn't match the expected shape or is too large, filters out bots, and allows each visitor at most 30 reports a minute. Each check answers one "what if".

Measure, form a hypothesis, test

Years of lab reports trained one loop into me: measure, form a hypothesis, change one thing, measure again.

The loop works best when you measure after every change, so this site does. Each pull request runs Lighthouse, Google's page-speed test, on six pages, for both phones and desktops. If a page scores below 90 on a phone or 95 on a desktop, the check fails. Only one change is in front of me at that point, so I already know where the problem is.

It's like a sensor on every pipe: a problem shows up where it starts, not three units downstream.

Set a target and control to it

Process control is about keeping a value at its setpoint: a temperature, a pressure, a flow. You measure, compare with the target and correct.

/stats works the same way. The target is that 95% of page views over the last 28 days get a "good" score on Google's page-speed metrics. The other 5% is a budget I'm allowed to spend. When it's spent, the page marks the goal as missed, and I know where to look.

What the degree didn't teach me

The habits transfer. The skills mostly don't. Chemical engineering taught me nothing about algorithms, data structures, databases, testing, version control or how the web works. Those came from six months of self-study, years of work and the master's.

I'm also far from unusual. In the 2020 Stack Overflow Developer Survey, 9.3% of professional developers with a university degree had studied an engineering subject other than computing. And the list of chemical engineers in computing is a good one: John von Neumann graduated as a chemical engineer from ETH Zurich, and Intel's Andy Grove earned both his degrees in chemical engineering.

If you're switching careers too, my advice is simple: don't throw your first degree away. Look for the way of thinking it gave you, and use it.

If you've already made the switch, I'd like to hear which habits came with you. Tell me on LinkedIn.