IT/EN
← All notes

Pl. VIMedicine· 2 min read

Why a medical student should learn to code

Not to become a developer, but to think differently about clinical problems. Notes from someone who came to Medicine after five years of Computer Science.

I came to Medicine after five years of Computer Science. They look like distant worlds; in reality they have more in common than it seems.

Medicine is a science of uncertainty and an art of probability. — William Osler

Thinking in systems

A program is a set of parts exchanging signals, with states, feedback loops and failures. So is physiology: a reflex is a control loop, a hormone is a message with a recipient and a lifetime, an arrhythmia is a timing problem.

And debugging (forming a hypothesis, isolating a variable, checking, repeating) is a lot like diagnostic reasoning. The same traps apply in both fields: falling in love with the first hypothesis, only looking at the data that confirms it.

Reading the data, not just the conclusions

Evidence-based medicine stands on statistics. Being able to simulate a phenomenon, even crudely, helps you understand what a paper is really saying: how big the effect is, how uncertain, what changes if you tweak an assumption. That is how my caffeine tolerance model was born: reading a study and wondering what would happen with different doses and schedules.

Writing a formula forces you to understand it

An example I will be using soon: on an ECG, the QT interval gets shorter as the heart speeds up. To compare it across heart rates it gets “corrected”, for instance with Bazett’s formula.

from math import sqrt

def qtc_bazett(qt_ms: float, rr_ms: float) -> float:
    """Heart-rate-corrected QT (Bazett's formula)."""
    return qt_ms / sqrt(rr_ms / 1000)

# 75 bpm → RR interval of 800 ms
print(round(qtc_bazett(380, 800)))  # 425

It is a few lines. But writing them forces you to ask why you divide by the square root of RR, which unit it should be in, and why Bazett tends to over-correct at high heart rates and under-correct at low ones. The same principle drives the simulated trace on Plate VI.

Automating the boring parts

Flashcards generated from your notes, scripts that tidy up the sources for an essay, small simulators to practise with: code is also a way to free up time for actual studying.

Understanding the tools you will use

Algorithms and artificial intelligence will play a growing part in clinical practice: risk scores, triage, image analysis. You don’t need to be able to build them all. You need to know how they work well enough to tell when not to trust them.