Computing with Whole Arrays
Scientific computing rarely means writing every algorithm from scratch. Modern practice rests on two pillars: vectorised computation and numerical libraries.
Vectorisation expresses operations on whole arrays at once rather than element by element with explicit loops. Instead of "for each i, set c[i] = a[i] + b[i]," you write c = a + b — one operation on entire arrays. This is not just shorter; it is dramatically faster. Explicit loops in a high-level interpreted language are slow, but a vectorised operation dispatches to highly optimized, compiled code (often using the CPU's parallel SIMD instructions) that processes many elements per cycle. Vectorised code is both more readable (it looks like the mathematics) and far more efficient.
Numerical libraries provide expertly implemented, tested, and optimized routines so you never reimplement the fundamentals. The scientific stack — array libraries (NumPy-style), linear-algebra packages (built on BLAS/LAPACK), and plotting and data tools — offers matrix operations, solvers, transforms, statistics, and more. These libraries encode decades of numerical expertise: they handle pivoting, stability, and edge cases correctly, which naive hand-written code usually does not.
The professional principle: do not reinvent the wheel. A hand-coded linear solver will almost certainly be slower and less numerically robust than the library routine, which has been refined and stress-tested for years. The scientific programmer's skill is composing well-chosen library operations — and knowing what they do and their limitations — rather than reimplementing them. Vectorised thinking (operate on arrays) plus library fluency (call the right optimized routine) is the modern idiom of scientific computing.
Common pitfall: writing slow explicit element-by-element loops where a vectorised array operation would be far faster, and reimplementing numerical routines that robust libraries already provide. In array-based scientific computing, an explicit loop over elements can be orders of magnitude slower than the equivalent whole-array operation dispatched to optimized compiled code. And a hand-written solver rarely matches a library's speed or numerical robustness — prefer well-tested library routines to reinventing the wheel.