Foundations: Programming and Abstractions
“Out of intense complexities intense simplicities emerge.” — Winston Churchill (1923)
Over the next several chapters, we build essential concepts that enable sophisticated financial models while maintaining clarity and control. We begin with core programming building blocks—the vocabulary and grammar of communicating with computers. From there, we explore how to decompose complex problems through abstraction: functions and methods, structs and parametric types, and multiple dispatch as the organizing principle.
Abstraction is selective attention—focusing on what matters for a given purpose while hiding irrelevant detail. Just as financial statements aggregate transaction‑level noise to reveal performance and risk, thoughtful abstraction lets us manage complexity by working at the right level of detail: a pricing function that hides payoff minutiae, a portfolio type that encapsulates assets and weights, or a generic risk routine that dispatches on instrument type.
The goal is not to make you a computer scientist, but rather to equip you with the mental models and practical techniques needed to effectively leverage programming in your financial work. By understanding these foundations, you’ll be better equipped to design clean, maintainable models that can evolve with your needs.
Think of this section as building your modeling toolkit, one concept at a time. We’ll introduce ideas progressively, with plenty of concrete examples to ground the theory in practical application. The concepts build on each other, so take time to ensure your understanding before moving forward. Let’s begin with the fundamental elements of programming.