Latest / CyberSecurity Summary / C++ for Financial Mathematics (Chapman and Hall/CRC Financial Mathematics Series)
Transcript
- 0:00Speaker 1: In twenty twelve, there was this this single dormant piece
- 0:04Speaker 1: of code that got accidentally triggered at a financial firm
- 0:07Speaker 1: called Night Capital, and in just forty five minutes, that
- 0:10Speaker 1: one piece of code lost the company four hundred and
- 0:13Speaker 1: forty million dollars.
- 0:15Speaker 2: Yeah, that's I mean, that is roughly ten million dollars
- 0:18Speaker 2: a minute, just gone right.
- 0:20Speaker 1: And there were no hackers involved, you know, no masked
- 0:23Speaker 1: bank robbers making a getaway in a van. It was
- 0:26Speaker 1: literally just a software bug.
- 0:27Speaker 2: It's terrifying, really, but it perfectly exposes the reality of
- 0:31Speaker 2: our modern financial system because you know, the fixed steel
- 0:34Speaker 2: vaults and armored trucks we always picture when we think
- 0:36Speaker 2: of banks, that's mostly just theater.
- 0:38Speaker 1: Now, yeah, the physical stuff exactly.
- 0:40Speaker 2: The actual wealth of the world is just a landscape
- 0:42Speaker 2: made entirely of code. And when you are dealing with
- 0:45Speaker 2: a system executing thousands of trades a second, a single
- 0:49Speaker 2: misplaced character doesn't just like crash an app on your phone.
- 0:52Speaker 2: It vaporizes capital.
- 0:54Speaker 1: Which makes this the perfect time for you listening to
- 0:57Speaker 1: this right now to join us as we step out
- 0:59Speaker 1: of the physical vault and dive into the invisible machinery
- 1:03Speaker 1: of global finance. Our guide today for this deep dive
- 1:07Speaker 1: is a really fascinating breakdown of the high wire world
- 1:10Speaker 1: of the quant developer.
- 1:11Speaker 2: We're using John Armstrong's textbook C plus plus for Financial
- 1:15Speaker 2: Mathematics as our map.
- 1:16Speaker 1: Here, right, and our mission today is to look at
- 1:19Speaker 1: these mathematical programmers, the ones who build the massive platforms
- 1:23Speaker 1: that price these ridiculously complex financial portfolios.
- 1:27Speaker 2: We are going to unpack why the notoriously difficult, super
- 1:31Speaker 2: unforgiving programming language C plus plus remains the absolute backbone
- 1:36Speaker 2: of the banking industry.
- 1:37Speaker 1: Yeah, and we'll see how its rigidly strict rules are
- 1:40Speaker 1: essentially the only thing preventing those those billion dollar headline
- 1:44Speaker 1: making catastrophes like Night Capital exactly. Okay, let's unpack this
- 1:47Speaker 1: because a scale we're dealing with is kind of hard
- 1:49Speaker 1: to wrap your head around. A major bank isn't just
- 1:51Speaker 1: you know, balancing a giant spreadsheet ledger at the end
- 1:53Speaker 1: of the day.
- 1:54Speaker 2: Oh no, not at all.
- 1:55Speaker 1: They have trading positions spread across global exchanges New York, London, Tokyo,
- 2:02Speaker 1: dynamically trading stocks, derivatives, currencies, commodities. The data flow is
- 2:07Speaker 1: just exponential, and the code runs twenty four hours a day,
- 2:11Speaker 1: seven days a week.
- 2:12Speaker 2: And the central challenge here isn't merely doing the advanced math,
- 2:15Speaker 2: though the math is obviously complex. The real problem is
- 2:18Speaker 2: scalability and will maintainability.
- 2:21Speaker 1: Keeping the whole thing from collapsing. Right.
- 2:24Speaker 2: When a system reaches that level of complexity, no single
- 2:27Speaker 2: human mind can hold the entire architecture. You have hundreds
- 2:30Speaker 2: of programmers working on the exact same live code, based simultaneously.
- 2:33Speaker 1: And C plus plus became the tool of choice for this,
- 2:36Speaker 1: which is wild because it emerged back in what nineteen eighty.
- 2:40Speaker 2: Three, yeah, early eighties. It took the raw speed of
- 2:42Speaker 2: the older Sea language and added object oriented programming.
- 2:46Speaker 1: Which essentially means organizing code into discrete objects, right, allowing
- 2:50Speaker 1: massive teams to build different pieces without constantly overwriting each
- 2:53Speaker 1: other's work.
- 2:54Speaker 2: Exactly. By the nineteen nineties, when Wall Street and Global
- 2:58Speaker 2: Banks were racing to build out their first really massive
- 3:01Speaker 2: electronic trading platforms, C plus plus was the mature, heavy
- 3:05Speaker 2: hitting tool that was available. It had the speed to
- 3:07Speaker 2: beat competitors to a trade and the structure to handle
- 3:10Speaker 2: the sheer size of the operation.
- 3:13Speaker 1: But and I have to push back here if I'm
- 3:15Speaker 1: looking at software engineering today, languages like Python or Java
- 3:19Speaker 1: or c sharp are everywhere. I mean, they are significantly
- 3:23Speaker 1: easier to learn and far less punishing. C plus plus
- 3:26Speaker 1: is kind of infamous for being difficult to master. Oh
- 3:28Speaker 1: it's brutal right, A tiny punctuation error derails the whole operation.
- 3:32Speaker 1: So if a massive bank has virtually infinite resources, why
- 3:36Speaker 1: not just rewrite the system in something modern, saber, and easier.
- 3:40Speaker 2: What is fascinating here is the sheer gravity of legacy
- 3:44Speaker 2: lock in. Rewriting isn't just about paying programmers to type
- 3:47Speaker 2: new code. It's about tearing up the foundation of a
- 3:50Speaker 2: city while millions of people are still living in it.
- 3:52Speaker 1: That's a good way to put it.
- 3:53Speaker 2: A legacy bank has spent thirty years writing millions upon
- 3:57Speaker 2: millions of lines of highly specific, in locking C plus
- 4:01Speaker 2: plus code. They have all their institutional knowledge entirely wrapped
- 4:05Speaker 2: up in that specific environment.
- 4:07Speaker 1: So you can't just hit a pause button on the
- 4:09Speaker 1: global market for a year to swap out the plumbing.
- 4:11Speaker 2: You really can't. And to see how extreme this lock
- 4:14Speaker 2: in gets, just look at Goldman Sachs from the source text.
- 4:16Speaker 2: They don't even use standard C plus plus for much
- 4:19Speaker 2: of their core pricing architecture. They built a completely proprietary
- 4:23Speaker 2: language called slang.
- 4:24Speaker 1: Wait really slang. So if you dedicate years to mastering slang,
- 4:29Speaker 1: you can literally only use it at one company in
- 4:32Speaker 1: the entire world.
- 4:33Speaker 2: That is the reality. They are bound to it, just
- 4:35Speaker 2: as other massive institutions are bound to C plus plus lang.
- 4:39Speaker 2: It's not really a debate over whether C plus plus
- 4:41Speaker 2: is the undisputed objective best language ever created. It is
- 4:45Speaker 2: simply the pragmatic reality of the industry's infrastructure.
- 4:49Speaker 1: Okay, so if banks are locked into this high performance
- 4:52Speaker 1: legacy infrastructure, we really need to understand how C plus
- 4:55Speaker 1: plus forces these quant developers to communicate with the machine.
- 5:00Speaker 1: And a massive part of that is how a language
- 5:03Speaker 1: interacts with the computer's central processing unit, the CPU.
- 5:06Speaker 2: Right because C plus plus is a compiled language, which
- 5:09Speaker 2: is fundamentally different from something like Python.
- 5:11Speaker 1: Yeah, very different. Yeah, because Python is interpreted right. Yeah,
- 5:14Speaker 1: that means the computer translates the human readable code into
- 5:17Speaker 1: machine instructions on the fly, like right as the program
- 5:19Speaker 1: is running.
- 5:20Speaker 2: Exactly, But C plus plus requires you to compile everything first.
- 5:24Speaker 2: Every single instruction is converted into machine code, you know,
- 5:26Speaker 2: the raw ones and zeros, the CPU actually processes long
- 5:30Speaker 2: before the program is ever allowed to execute, which brings.
- 5:32Speaker 1: Us to static typing. In C plus plus A, you
- 5:35Speaker 1: can't just create a variable called price and just throw
- 5:39Speaker 1: a number into it. You have to explicitly declare the
- 5:42Speaker 1: exact data type upfront.
- 5:44Speaker 2: Yes, you have to tell the compiler exactly what's coming.
- 5:47Speaker 1: Right, you say, this is an end for an integer,
- 5:51Speaker 1: or wool for a booleon, or a double for a
- 5:53Speaker 1: highly precise floating point number. But since you know you
- 5:57Speaker 1: listening probably know what an integer is, why is this
- 6:00Speaker 1: so obsessed with these labels.
- 6:02Speaker 2: It all comes down to memory allocation. The CPU doesn't
- 6:05Speaker 2: know what a price is, right, It just sees an
- 6:06Speaker 2: empty block of memory. So when you declare an int,
- 6:10Speaker 2: you are telling the computer to set aside exactly four
- 6:12Speaker 2: bytes of physical memory. Okay, And when you declare a
- 6:16Speaker 2: double for decimals, you are telling it to set aside
- 6:19Speaker 2: eight bytes. You are literally carving out the physical space
- 6:22Speaker 2: on the hardware before the data even arrives.
- 6:25Speaker 1: Here's where it gets really interesting, because if the CPU
- 6:28Speaker 1: is just looking at raw bytes, static typing is basically
- 6:31Speaker 1: a child's sheep sorting toy.
- 6:33Speaker 2: Oh that's a perfect analogy.
- 6:34Speaker 1: Yeah, you're forcing the programmer to define the peg in
- 6:37Speaker 1: the hole perfectly, like putting diesel in the petrol car.
- 6:40Speaker 1: It just won't fit. By demanding that declaration, the compiler
- 6:44Speaker 1: acts like a bouncer at the door. Right. It stops you.
- 6:46Speaker 1: It stops you if you accidentally try to. I don't
- 6:49Speaker 1: know multiply the letter W by the number seven because
- 6:53Speaker 1: it knows Wo's character taking up one byte, and seven
- 6:56Speaker 1: is an integer taking up four bytes.
- 6:57Speaker 2: The sheep sorting analogy captures the mechanism perily, because the
- 7:00Speaker 2: CPU is completely blind to context. If you feed it binary,
- 7:04Speaker 2: it will blindly execute the math. And the quirks of
- 7:07Speaker 2: how C plus plus views data types show just how
- 7:10Speaker 2: painfully literal the language is.
- 7:13Speaker 1: The integer division thing is wild.
- 7:15Speaker 2: Yes, take integer division. If a developer divides the integer
- 7:19Speaker 2: three by the integer five, C plus plus doesn't give
- 7:22Speaker 2: you point six. It insists the result must also be
- 7:24Speaker 2: an integer, So it just chops off the decimal entirely
- 7:27Speaker 2: and gives you zero.
- 7:28Speaker 1: Wait, it doesn't even round it up or down. It
- 7:30Speaker 1: just violently lops off the fraction.
- 7:31Speaker 2: She just throws it away, which is why financial math
- 7:34Speaker 2: relies so heavily on the double data type. For floating
- 7:37Speaker 2: point arithmetic, you need those decimals, but even a double
- 7:40Speaker 2: has physical memory limits. You cannot store infinite decimal places
- 7:45Speaker 2: in eight boats.
- 7:46Speaker 1: Right, Eventually you run out of physical space exactly.
- 7:49Speaker 2: So at a microscopic level, floating point numbers can lose
- 7:52Speaker 2: tiny fractions of precision.
- 7:54Speaker 1: And in a multimillion dollar trading algorithm, losing a tiny
- 7:57Speaker 1: fraction of a penny across ten million ship suddenly becomes
- 8:01Speaker 1: a very real problem.
- 8:03Speaker 2: It adds up fast.
- 8:04Speaker 1: It's also wild to see the history baked into these types,
- 8:07Speaker 1: Like the chart type meant for single characters. Armstrong points out,
- 8:11Speaker 1: it's essentially mapped to nineteen sixties American teleprinter standards.
- 8:15Speaker 2: Yeah, they ASKI standards right.
- 8:16Speaker 1: It includes a specific byte command, the backslash, a character
- 8:21Speaker 1: that physically tells the sine to make a ping sound
- 8:24Speaker 1: like an actual bell, which used to alert an operator
- 8:27Speaker 1: that a paper printout was finished.
- 8:29Speaker 2: It is such a bizarre artifact to have in modern
- 8:32Speaker 2: banking software. But that strictness demanding you know exactly what
- 8:35Speaker 2: type of bite you are dealing with is a defense mechanism.
- 8:38Speaker 2: A compiled, statically typed language is designed to catch logic
- 8:42Speaker 2: errors during that compilation phase, long before the code is
- 8:45Speaker 2: employed to a live trading floor.
- 8:46Speaker 1: But developers can sometimes override or ignore the compiler when
- 8:50Speaker 1: it flags something suspicious. Right, Like, it throws a warning
- 8:54Speaker 1: and you could just shrug and proceed anyway you can.
- 8:56Speaker 2: But in quant finance that is an absolute cardinal sin.
- 9:00Speaker 2: Developers are trained to configure their compilers to treat all
- 9:03Speaker 2: warnings as fatal.
- 9:04Speaker 1: Errors because the stakes are so high.
- 9:06Speaker 2: Right if you accidentally cast a double into an ind
- 9:09Speaker 2: that the compiler might just say warning, possible loss.
- 9:13Speaker 1: Of data because it's about to chop off the decimal.
- 9:15Speaker 2: Precisely, if you let that program run, it silently throws
- 9:19Speaker 2: away the decimal, and in finance, throwing away the decimal
- 9:21Speaker 2: means silently throwing away money. The program doesn't crash, so
- 9:24Speaker 2: you don't even know you're bleeding capital until the accounts
- 9:27Speaker 2: do not reconcile at the end of the day.
- 9:29Speaker 1: Wow. Okay, So catching those data type mismatches early is critical.
- 9:34Speaker 1: But a trading system isn't just a static list of
- 9:37Speaker 1: correctly labeled data. It is a massive, dynamic web of
- 9:41Speaker 1: mathematical logic. If I have a million trades to process.
- 9:45Speaker 1: I'm not writing a million separate lines of math. So
- 9:47Speaker 1: how do we structure the logic so it doesn't collapse
- 9:50Speaker 1: into a tangled mess.
- 9:51Speaker 2: Well, we compartmentalize. You take complex math and lock it
- 9:56Speaker 2: inside isolated, reusable blocks called functions. C plus plus provides
- 10:02Speaker 2: built in functions like pow for calculating exponents, but a
- 10:06Speaker 2: quant developer will write custom functions for their specific needs,
- 10:09Speaker 2: like norm CDF.
- 10:10Speaker 1: Which calculates the cumulative normal distribution.
- 10:13Speaker 2: Exactly. If you are pricing an options contract, you need
- 10:16Speaker 2: to calculate the probability that a stock price will hit
- 10:19Speaker 2: a certain target by a certain date. That probability heavily
- 10:23Speaker 2: relies on the cumulative normal distribution.
- 10:25Speaker 1: That sounds like a lot of heavy.
- 10:26Speaker 2: Math, it is, so instead of writing that dense statistical
- 10:30Speaker 2: math every single time you price an option, you write
- 10:32Speaker 2: the norm CDF function once and just call its name
- 10:35Speaker 2: whenever you.
- 10:36Speaker 1: Need it, which leads to the absolute golden rule of
- 10:39Speaker 1: software engineering mentioned in the source Once and only once. Yeah,
- 10:43Speaker 1: you never ever copy and paste a block of code.
- 10:45Speaker 2: Never. I mean, think about the maintenance nightmare if you
- 10:48Speaker 2: copy a block of logic into one hundred different places
- 10:50Speaker 2: and then discover a subtle flaw in the risk probability map.
- 10:53Speaker 1: You have to go hunting for that exact block of
- 10:56Speaker 1: code in one hundred different files and just pray you
- 10:58Speaker 1: don't miss one. But if it's isolated in a function,
- 11:02Speaker 1: you fix the math inside the function, and instantly every
- 11:05Speaker 1: part of the trading system calling that function is using
- 11:08Speaker 1: the creded math exactly.
- 11:10Speaker 2: And as these massive libraries grow, functions can get incredibly complex.
- 11:15Speaker 2: They can even call themselves to solve problems in loops,
- 11:18Speaker 2: a concept called recursion. Programmers love building recursive logic.
- 11:23Speaker 1: Yeah, the booknoes. They also love hiding recursive jokes in
- 11:25Speaker 1: their naming conventions.
- 11:27Speaker 2: It is a very specific brand of humor.
- 11:28Speaker 1: Yeah.
- 11:29Speaker 2: Take the famous G and U software system. GNU is
- 11:32Speaker 2: a recursive acronym that stands for Gnus, not Unix. So
- 11:36Speaker 2: the G stands for GNU, which stands for genn Us,
- 11:39Speaker 2: not Unix, and it loops on into infinity.
- 11:42Speaker 1: That's deeply nerdy. But here's a practical problem. If you
- 11:45Speaker 1: have hundreds of programmers working globally, or your e merging
- 11:49Speaker 1: libraries from two different departments. Let's say the London desk
- 11:53Speaker 1: writes a function called average and they mean the statistical mean,
- 11:57Speaker 1: but the Tokyo desk writes a function called average mean
- 12:00Speaker 1: the median. If I compile this code based, does the
- 12:02Speaker 1: computer just panic because it doesn't know which average to use.
- 12:06Speaker 2: In older languages, yes, it would fail completely, It would
- 12:09Speaker 2: just throw its hands up. But C plus plus solves
- 12:12Speaker 2: this Using name spaces. You explicitly wrap a group of
- 12:15Speaker 2: functions inside a designated name space to keep them distinct.
- 12:19Speaker 1: So it's basically like adding a surname to your first
- 12:22Speaker 1: name at a crowded party. If I just yell hey, John,
- 12:25Speaker 1: three people might turn around. But if I yell John Armstrong,
- 12:28Speaker 1: everyone knows exactly who is being addressed.
- 12:31Speaker 2: That captures the mechanism perfectly. The standard C plus plus
- 12:34Speaker 2: library uses the name space std, so when you see
- 12:37Speaker 2: SDD colon colon in front of a command, that's the surname.
- 12:41Speaker 2: Tokyo can have their Tokyo colon colon average, and London
- 12:44Speaker 2: has London colon colon average. But keeping names organized is
- 12:48Speaker 2: really just the surface. You also have to tightly control
- 12:52Speaker 2: where your data lives, which brings us to the immense
- 12:54Speaker 2: danger of global variables.
- 12:57Speaker 1: Right variables that aren't locked inside a specific function. But
- 13:00Speaker 1: just sit out in the open where any part of
- 13:02Speaker 1: the program can see and modify them. Why are those
- 13:05Speaker 1: so uniquely dangerous in a financial.
- 13:07Speaker 2: System Because modern trading systems use multi threading. The computer
- 13:11Speaker 2: is executing multiple processes at the exact same millisecond to
- 13:15Speaker 2: save time. Imagine a global variable tracking the total cash
- 13:19Speaker 2: in an account. Thread A is processing a massive deposit,
- 13:23Speaker 2: THREADB is processing a massive withdrawal, and.
- 13:25Speaker 1: They both grab that global cash total at the exact
- 13:28Speaker 1: same microsecond.
- 13:29Speaker 2: Yes, they both read the same starting number. Thread A
- 13:32Speaker 2: adds the deposit and saves the new total. A millisecond later,
- 13:35Speaker 2: THREADBE subtracts the withdrawal from the original number it read
- 13:38Speaker 2: and saves its new total, completely overriding thread a's deposit.
- 13:42Speaker 1: Oh my god, the deposit just vanishes into thin air
- 13:45Speaker 1: because THREADBE didn't know thread A was doing math at
- 13:48Speaker 1: the same time.
- 13:49Speaker 2: That is what's called a race condition. The threads are
- 13:52Speaker 2: literally racing to update the same memory address. They collide,
- 13:56Speaker 2: the data corrupts, and you lose millions of dollars. By
- 14:00Speaker 2: forcing data into local variables, meaning it only exists safely
- 14:04Speaker 2: inside its specific function, you prevent those simultaneous collisions Okay.
- 14:09Speaker 1: So we have our data safely typed locked into local
- 14:12Speaker 1: variables and wrapped in functions. But how do we actually
- 14:15Speaker 1: unleash this logic? If I have a portfolio of ten
- 14:18Speaker 1: thousand stocks, I'm not writing ten thousand separate commands to
- 14:22Speaker 1: trigger the pricing function.
- 14:23Speaker 2: That is where flow of control comes in. We use loops,
- 14:26Speaker 2: specifically while do while and four loops to dictate how
- 14:30Speaker 2: the program moves through data. A four loop, for instance,
- 14:33Speaker 2: tells the CPU run this risk analysis function, step forward
- 14:37Speaker 2: to the next stock, and repeat until you hit the
- 14:39Speaker 2: end of the list.
- 14:40Speaker 1: And this brings up one of the most famously jarring
- 14:42Speaker 1: quirks of C plus plus L and programming in general.
- 14:45Speaker 1: When these loops count through a list, they don't start
- 14:48Speaker 1: at one. They always always start counting at zero.
- 14:50Speaker 2: Zero indexing. It is deeply ingrained in the architecture.
- 14:53Speaker 1: So what does this all mean? Why would humans force
- 14:57Speaker 1: their brains to adapt to the machine by starting at zero?
- 15:01Speaker 1: It seems like an arbitrary way to cause you know,
- 15:04Speaker 1: off by one errors.
- 15:05Speaker 2: Well, it feels arbitrary until you look at how the
- 15:07Speaker 2: CPU physically navigates memory, especially when dealing with multi dimensional
- 15:12Speaker 2: data like financial matrices. Think of memory as a massive
- 15:17Speaker 2: wall of physical mail cubbies.
- 15:19Speaker 1: Okay, I'm picturing a grid of cubbies.
- 15:21Speaker 2: If the very first cubby on the bottom left is
- 15:23Speaker 2: labeled zero, finding any other cubby is just a matter
- 15:26Speaker 2: of calculating the distance from the start. You just count
- 15:29Speaker 2: the exact number of steps right end up. The math
- 15:32Speaker 2: is incredibly clean.
- 15:34Speaker 1: Because zero is the baseline. Right.
- 15:36Speaker 2: But if you label that first cubby one, you suddenly
- 15:39Speaker 2: have to subtract one in your head every single time
- 15:41Speaker 2: you calculate the distance because your starting point is already offset.
- 15:44Speaker 1: Oh I see. So by starting at zero, the CP
- 15:46Speaker 1: doesn't have to perform an extra subtraction operation every single
- 15:49Speaker 1: time it moves to a new cell in a massive.
- 15:51Speaker 2: Matrix, exactly when you are processing billions of data points
- 15:56Speaker 2: in a high frequency trading matrix. Removing that single unnecessary
- 16:00Speaker 2: subtraction step creates a massive leap in processing speed and
- 16:03Speaker 2: mathematical elegance that.
- 16:05Speaker 1: Actually makes total sense. But no matter how perfectly elegant
- 16:09Speaker 1: the loops and matrices are, something external is going to fail. Eventually.
- 16:13Speaker 1: A network drops, a data feed goes down. How does
- 16:16Speaker 1: the flow of control handle errors without crashing the whole server.
- 16:20Speaker 2: Through error handling mechanisms like the throw statement. When a
- 16:24Speaker 2: function detects an impossible scenario like a failed overdraft check,
- 16:27Speaker 2: it literally throws an exception.
- 16:29Speaker 1: Basically pulling the fire alarm in the building. Everything stops.
- 16:33Speaker 2: But wait, why is it better to pull the fire
- 16:35Speaker 2: alarm If a single trade fails, wouldn't a bank want
- 16:38Speaker 2: the system to just log the error in a background
- 16:41Speaker 2: file and keep processing the other nine hundred and ninety
- 16:43Speaker 2: nine trades. Limping along seems better than halting entirely.
- 16:46Speaker 1: That is a very common intuition, but in automated trading
- 16:50Speaker 1: it is a catastrophic mistake. Armstrong's book is very clear
- 16:53Speaker 1: on this. It is always better to fail obviously than
- 16:56Speaker 1: to fail subtly.
- 16:57Speaker 2: Really, because nobody is reading the server log file in
- 17:00Speaker 2: real time, these programs run completely unattended on servers in
- 17:04Speaker 2: remote data centers. If a program just silently prints overdraft
- 17:07Speaker 2: failed to a text file and keeps running the rest
- 17:10Speaker 2: of the algorithm, the system assumes the trades succeeded.
- 17:14Speaker 1: Oh wow, so it starts executing secondary trades based on
- 17:17Speaker 1: money that didn't actually clear.
- 17:18Speaker 2: Yes, a silent failure cascades into a massive financial crater.
- 17:23Speaker 2: So you pull the fire alarm, you terminate the program.
- 17:26Speaker 2: You force a human developer to investigate the root cause
- 17:28Speaker 2: immediately before another dollar moves.
- 17:30Speaker 1: Wow. So we have statically typed memory, isolated functions, zero
- 17:34Speaker 1: index loops, and trip wires to pull the fire alarm.
- 17:37Speaker 1: As a quant developer builds this out into a massive
- 17:39Speaker 1: library like the fm lib project outlined in the source.
- 17:43Speaker 1: Keeping millions of lines of code in one giant text
- 17:45Speaker 1: document becomes well physically impossible for a computer to open,
- 17:49Speaker 1: let alone for a human to.
- 17:51Speaker 2: Read, which brings us to the architecture of the files themselves.
- 17:54Speaker 2: C plus plus solves this by physically splitting the architecture.
- 17:57Speaker 2: You have header files which end in dot dah and
- 17:59Speaker 2: source files which end in dot DApp.
- 18:01Speaker 1: I want to focus on why this two file system
- 18:04Speaker 1: is the ultimate defense against chaos. What is the mechanism here?
- 18:08Speaker 2: Think of the header file as the restaurant menu. It
- 18:12Speaker 2: contains the declarations. It simply lists what functions exist, their names,
- 18:16Speaker 2: and what data types they require. It does not explain
- 18:19Speaker 2: how the math works.
- 18:20Speaker 1: Okay, so it's just a list of options exactly.
- 18:22Speaker 2: The source file is the kitchen recipe. It contains the definitions,
- 18:26Speaker 2: the actual complex nitty gritty code that executes the math.
- 18:30Speaker 1: And combining them is a three stage process. Right, The
- 18:33Speaker 1: preprocessor glues the text together, the compiler turns it into
- 18:36Speaker 1: machine code, and then the linker acts like the waiter
- 18:39Speaker 1: connecting the menu item to the actual recipe in the kitchen.
- 18:43Speaker 2: Yes, the linker resolves the function calls, and this architecture
- 18:46Speaker 2: enables something really critical. Information hiding developers use a special
- 18:51Speaker 2: keyword static to deliberately hide internal helper functions inside the
- 18:56Speaker 2: source file, keeping them completely off the header file menu.
- 18:59Speaker 1: But counterintuitive to me. If you are working on a
- 19:02Speaker 1: team of one hundred quant developers at a bank, why
- 19:06Speaker 1: would you intentionally hide your own code from your colleagues?
- 19:09Speaker 1: Should software development be open.
- 19:11Speaker 2: And collaborative collaboration is great, but dependencies are a nightmare.
- 19:15Speaker 2: If you put a helpful little function on the header menu,
- 19:19Speaker 2: your colleagues will see it and they will start using
- 19:21Speaker 2: it in their own algorithms. And once they do that,
- 19:24Speaker 2: you are trapped because.
- 19:26Speaker 1: If I realize my helper function needs an upgrade and
- 19:28Speaker 1: I alter the math or change the data type.
- 19:31Speaker 2: You just broke your colleagues billion dollar trading algorithm. You
- 19:34Speaker 2: can never fundamentally change that function again without breaking their code.
- 19:38Speaker 2: There's an old, incredibly pragmatic programming joke about this mentioned
- 19:42Speaker 2: in the text Programming is like sex. One mistake and
- 19:46Speaker 2: you have to support it for the rest of your life.
- 19:48Speaker 1: Oh man, That is painfully accurate for software. So information
- 19:52Speaker 1: hiding is purely defensive architecture.
- 19:55Speaker 2: It really is. You only expose the absolute minimum required
- 19:58Speaker 2: interface on the header. Manl it ensures you can freely
- 20:02Speaker 2: rewrite and optimize the hidden math in your kitchen without
- 20:05Speaker 2: ever worrying about breaking someone else's system.
- 20:08Speaker 1: Although the source does mention a workaround for when speed
- 20:11Speaker 1: is more important than structure, the inline keyword right.
- 20:16Speaker 2: Normally, calling a function via the linker takes a microscopic
- 20:19Speaker 2: fraction of a microsecond of overhead, but in something like
- 20:22Speaker 2: a Monte Carlo simulation running millions of iterations, those fractions
- 20:27Speaker 2: add up.
- 20:27Speaker 1: So labeling a function inline tells the compiler to physically
- 20:30Speaker 1: copy paste the machine code directly into the loop, giving
- 20:34Speaker 1: you the blistering speed of raw code without forcing the
- 20:37Speaker 1: human developer to actually break the once and only once rule.
- 20:40Speaker 1: The machine does the dirty work exactly.
- 20:42Speaker 2: It is a perfect example of giving the compiler permission
- 20:45Speaker 2: to optimize at the raw hardware level while the developers
- 20:48Speaker 2: maintain their clean, defensive architecture above ground.
- 20:51Speaker 1: We have covered incredible ground today. We journeyed from the
- 20:54Speaker 1: high stakes, billion dollar scale of global banks through the
- 20:58Speaker 1: strict memory allocation of C plus compilers. We unpacked how
- 21:02Speaker 1: developers build logical safety nets to prevent race conditions, map
- 21:07Speaker 1: the mathematical elegance of counting from zero, and explored the
- 21:10Speaker 1: defensive architecture of hiding code just to survive a massive
- 21:14Speaker 1: collaborative environment.
- 21:16Speaker 2: And I think it reveals that global finance isn't just
- 21:18Speaker 2: driven by economic theory. It is fundamentally constrained and enabled
- 21:23Speaker 2: by the rigid realities of computer science.
- 21:25Speaker 1: Absolutely so to you, the learner. The next time you
- 21:29Speaker 1: glance at a sleek banking app on your phone, or
- 21:31Speaker 1: watch a stock ticker flashing green and red, remember the
- 21:34Speaker 1: invisible machinery underneath. Beneath that polish is a quant developer
- 21:38Speaker 1: particulously counting from zero, guarding their local variables, and praying
- 21:42Speaker 1: to the tech gods that their code compiles without a
- 21:45Speaker 1: single silent warning.
- 21:46Speaker 2: Because in their world, a warning isn't just a suggestion,
- 21:49Speaker 2: It is a potential catastrophe, which.
- 21:51Speaker 1: Leads us, with a final thought, to mollover if the
- 21:54Speaker 1: entire global financial system is absolutely dependent on language design
- 21:58Speaker 1: in the nineteen eighties, These massive institutions are locked in
- 22:02Speaker 1: because the sheer weight of their legacy code makes it
- 22:04Speaker 1: impossible to switch. Our modern financial markets ultimately bound by
- 22:09Speaker 1: the architectural quirks of forty year old computer science. And
- 22:12Speaker 1: if so, how many other invisible systems in our daily
- 22:15Speaker 1: lives are power grits, aviation networks, healthcare databases are simply
- 22:19Speaker 1: too big to fail and entirely too complex to ever
- 22:22Speaker 1: be rewritten.