Yellow marks are automatic key passages. They aren’t personal saved highlights. Select a timestamp to follow along with the video.
Fighter pilot-style software is built on removing risky features from a language rather than adding them. The video traces how aerospace moved from mechanical flight controls to software-heavy aircraft, from the F-14's early microprocessor through the Ada mandate to the Lockheed Martin decision to use a restricted C++ subset known as the JSF standard. It then walks through a demonstration in which a flight-data calculator is rewritten to remove exceptions, recursion, and dynamic memory allocation, and it ends by noting that the JSF standard, though historically important, is now best replaced by modern guidelines such as the C++ Core Guidelines.
Why Failure Is Not an Option
At Mach 1, there is no time for a garbage collector. In most programs, a bug is only an inconvenience, and a crash just means restarting the app. But what happens when failure isn't an option, and a single bad line of code can be a catastrophe? The obstacle is not really what is in the code. It is the difficulty of quantifying what you take out of it. This piece explains how to program like a fighter pilot.
The Ariane 5 Failure
On June 4, 1996, a warm morning in French Guiana, hundreds of spectators stood to watch the launch of Europe's newest rocket, the Ariane 5. At 9:33 a.m. local time, the solid boosters fired. For 36 seconds the flight was perfect. Then a single unhandled exception was thrown deep inside the flight control software. A 64-bit floating-point value of horizontal bias was converted to a 16-bit integer. The language did exactly what it was allowed to do, which was to trigger an error that the system could not handle. Roughly half a billion dollars was destroyed in an instant. In this case, an exception was detected but was not properly handled.
Remove Before Flight and the F-35 Standard
Designers of the F-35 decided they would not repeat this kind of mistake. The Joint Strike Fighter C++ coding standard, in its section on fault handling, includes AV Rule 208, which states that exceptions shall not be used. This is a clear example of 'remove before flight': by cutting certain features out of a target language, engineers can build something safer. Before going further, it is worth asking how the field got to this point, what it means to program like a fighter pilot, why it matters, and why there is a GameCube on the desk. The answer to the last question will become clear later.
Remove Before Flight Earrings and the Demo Plan
The presenter is also wearing remove-before-flight earrings, which is a playful nod to the concept. They are the kind of thing you should take out before flying a plane, since they could be slapped against your face during flight. This is not meant to be only a history video. The best way to learn is to work directly with the code. The plan is a demonstration in C++ that follows the strict JSF standard and connects to an F-35 inside a flight simulator. First, though, some pivotal moments that made C++ possible in aerospace are worth covering, and the path there turned out to be harder than most people expect. That includes the language battles fought inside the Pentagon.
Aircraft as Software
The language battles in the Pentagon were not as frightening as they sound. Modern aerospace, particularly military aircraft, is far more about software than hardware. Many people will likely disagree with this, but it is worth considering. A modern fighter is less like a plane that happens to have a computer and more like a computer that happens to be a plane.
Early Military Aircraft Without Software
In the early 1970s, military fighters such as the F-4 Phantom had essentially no software. The Department of Defense has stated that the F-4's bombing computer was little more than a box of gears and cams, similar to a precision watch. The so-called code was really just the shape of the metal cams. This began to change with a top-secret Navy air superiority project called VFX, which became the F-14 Tomcat.
The F-14 Microprocessor That Came First
Few people know that the first microprocessor was not created by Intel. Textbooks list the Intel 4004 as the world's first microprocessor, but that is because the F-14's processor was kept secret. Garrett AiResearch created a microprocessor for the F-14 years before Intel built its chip, and it was significantly faster. The main reason was the F-14's swing-wing design, where manual pilot control would have been far too demanding for optimal performance, especially during high-G maneuvers. The information was not declassified until 1998, because the Navy wanted to keep it from the Soviets. The processor did not have lines of code in the classic sense. It was physically burned microcode that processed polynomial equations, about 2,500 lines in total. This was the beginning of the first real software on an aircraft. A passing plane briefly interrupted the discussion during this part of the recording.
Fragmented Early Software
The early software era was a mess. The US Army, Air Force, and Navy each had completely different coding standards, and most people today have probably never heard of them. The Air Force used JOVIAL, which stands for Jules's Own Version of the International Algorithmic Language. It was something like the military grandchild of ALGOL. The Navy wanted its own language, so it did not adopt JOVIAL, which was designed for Air Force problems. The F-18 became the flagship example of the Navy's language, CMS-2. The result was two different languages, two different hardware architectures, and no compatibility.
Exponential Growth in Flight Code
The military recognized that the amount of onboard flight software was increasing exponentially. To put it in perspective, the F-16A had about 125,000 lines of code, the B-1 had about a million, and the F-35 carries about 9 million lines onboard. That trajectory is dramatic, and it is the kind of exponential curve that makes the problem clear.
A Code Jungle and the Push for One Language
The code was becoming a massive jungle that was difficult to audit. At one point, more than 450 programming languages were reportedly in use, and none had a proper standard. The solution was to create a new high-level language that would replace these scattered languages. That language became Ada.
The Ada Mandate
The Department of Defense wanted Ada adopted so strongly that it issued a mandate. A contractor who did not want to use Ada had to physically prove that it could not be used for the task. In practice, a project that did not use Ada risked losing the contract.
Ada's Strengths and the Shift to C++
Many developers code in C++ every day but may be unfamiliar with Ada, or may never have used it at all. Ada is well suited to safety-critical applications, which are vital in aerospace. The Ada mandate lasted about 15 years before problems began to surface. In the 1990s, nearly everything in aerospace ran on Ada. Meanwhile, the internet arrived, Windows 95 launched, and most popular games were written in C++. Staying stuck with Ada looked increasingly unappealing. A student in the 1990s who wanted a well-paid software job would not learn Ada.
Why Students Chose Free Compilers
Compilers once cost real money, often thousands of dollars for Ada. Today, most compilers are free, which makes it easy to forget the cost. Students at the time moved toward C++ and the free GCC compiler, joining what amounted to a free software movement. That shift became a problem for the F-35 program.
Lockheed Martin's Proposal to Use C++
Lockheed Martin expected the F-35 to be extremely software-heavy, with many complex concepts and calculations, such as sensor fusion. To address the risks, the company set out to achieve something that seemed impossible: convincing the Department of Defense to allow C++ instead of Ada. The person who first proposed this deserves respect, since the idea was either crazy or extraordinarily determined. The proposal amounted to contractors asking the Pentagon for permission to break the rules and use an unsafe language, while setting aside every other software mandate. The company did not go in unprepared, though. It planned to tame the language rather than use raw C++.
Consulting Bjarne Stroustrup
Who better to advise on a plan for selectively using C++ than Bjarne Stroustrup, the creator of C++? From personal experience, the presenter met Stroustrup at a conference and asked him a question about C++26 reflection capabilities. Stroustrup reportedly does not believe in the Java style of reflection. Stroustrup did admit that he had a hand in formulating the JSF rules, so he should be considered biased on the topic. The details of his involvement are somewhat fuzzy.
Surgically Removing Features from C++
This is how the Joint Strike Fighter's C++ standard works, and it fits the remove-before-flight concept. By surgically removing certain parts of an otherwise powerful language, developers can write code that is more likely to receive mission or safety certification, without being tied to an outdated language like Ada. The most surprising part is that anyone can read the JSF standard publicly online. This makes it possible to see how the F-35 is programmed, at least from a stylistic perspective.
An Open Joint Effort
The openness of the project lies partly in its name, Joint Strike Fighter. The aircraft was not built by Lockheed Martin alone. Many defense contractors and governments, including several countries, worked together on it as a group effort. Because the JSF standard is publicly available, in theory anyone could contribute compliant code to a billion-dollar aircraft program.
Learning by Writing Code
The best way to learn is to start writing C++ code while following the JSF standard. This may sound unusual, but the presenter once worked in this field, writing C++ for aerospace systems and giving demonstrations for the Air Force, and so spent a considerable amount of time in this world. The demonstration will be a heavily simplified version. It will focus mainly on the quirks of C++ within the JSF standard.
Flying in X-Plane 12
The most enjoyable part of the video is the flight simulator. The demonstration uses X-Plane 12, a popular flight simulator that is often used in industry. It is well suited to software integration testing and general flight demonstrations. A new flight is about to begin.
Starting the F-35B Simulation
The flight uses the F-35B, a model recently released by AOA Simulations that is both accurate and visually impressive. A new flight starts in X-Plane 12, and the simulator loads while the rest of the setup is prepared.
Building the Multifunction Display
The multifunction display, or MFD, is a custom build styled after F-16 displays, and it presents a wide range of flight data. It connects directly to X-Plane, which recently added a web API that clients can subscribe to. The MFD therefore receives a continuous live stream of flight data published over that API. The front end is written in Python, while the backend calculations run in C++. The main display shows position data, wind data, envelope data, button states, and navigation data. Connecting the buttons has exposed multithreading problems in the Python code, which makes that part harder to get working. All backend calculations must run in optimized C++ that follows the JSF standard, so that portion of the system is the focus of the demonstration.
Takeoff With Limited Visibility
The Top Gun-style glasses only slightly affect visibility of the computer screen, which in practice is a lot. The aircraft data updates live on the MFD throughout the flight, and the takeoff itself goes smoothly. Flying without clearly seeing the instruments is an unusual situation for a pilot, but the aircraft remains under control.
Maneuvers and Multitasking
The position data continues to update from the X-Plane web API while the aircraft is being flown, which makes multitasking between the display and the controls a real challenge. Attempts at a barrel roll are easy at first, but orientation quickly becomes confusing, and the pilot loses track of where the top of the aircraft is. Repeated pull-up warnings follow, and an attempt to dip a wing into the water fails. The pilot concludes that the Top Gun line about thinking too hard applies here.
Turning to the C++ Code
The most important part of the project is the C++ code, which is less visually exciting than the flight simulator but is more critical to the system. The X-Plane flight data plugin is available on GitHub, with a link provided in the description. The repository contains all of the important code that runs on the MFD.
Repository Structure
The file aircraft MFD.py handles only the graphical interface and is not especially interesting. The critical calculations live in the compliant and non-compliant folders, which are organized around the JSF standard. The non-compliant folder is the starting point for examining the code, since it contains the calculations that have not yet been brought into line with the standard.
Why Reliability Matters in the Calculations
The non-compliant folder contains the density altitude calculator, flight data processing, a turn calculator, VNAV data, and a wind calculator. Each of these calculations is either mission critical or safety critical, which means the C++ code must be completely reliable at all times. This requirement explains why such strict standards apply. The remove before flight tag is an important concept in this context, because it marks code that is allowed to exist in development but must be removed before the aircraft flies.
The Flight Calculator File
The flight calculator file is very long and heavily mathematical, and it is worth reading for those interested in aviation calculations. The file contains code related to memory allocation, and a potential issue exists there. The question is what could go wrong if this code runs without following the JSF standard. A second problem is also present in the file, and it is fairly obvious: one of the functions is highly unsafe to have on an aircraft.
The JSF C++ Standard
The JSF standard for C++, also known as the Joint Strike Fighter standard, is extremely long. Its table of contents shows how many topics it covers, ranging from stylistic guidelines to safety guidelines. Three main safety topics stand out for anyone who wants to program in the manner of a fighter pilot: memory allocation, exceptions, and recursion. The standard contains many more rules, but these three are the focus here. Safety in this standard comes largely from removing features from the language rather than adding them, which produces extremely predictable behavior.
Hardware Behind the F-35
The simulation runs on a Mac for simplicity, but the real hardware is much closer to a different platform. Early block F-35s used mission computers based on Motorola G4 PowerPC processors. This is public information, and articles from Aviation Today around 2003 discussed it. The processors were ruggedized and had special vector extensions and many other additions, but the core instruction set architecture remains similar. Technically, a GameCube uses an older generation of processor, so an even closer match would be an earlier design. Compiling code on that hardware to prove a point is not worth the effort.
Exceptions in Flight
Consider a C++ contractor who has written good code that has not yet been brought into line with the JSF standard. While a pilot is flying the aircraft and reviewing the available data, the numbers look good until an unhandled C++ exception occurs. Instead of handling it properly, the computer gives up completely, and the aircraft crashes shortly afterward. The first question is what happened inside the program, and the second is how to prevent it on an aircraft in the future. The answer begins with AV rule 208 of the JSF standard, which states that exceptions shall not be used. This rule can seem extreme, but the core problem is that exceptions generate an unpredictable flow of control.
The Ariane 5 Lesson
The Ariane 5 incident illustrates this problem. The failure was not caused by the value overflowing. It was caused by an unhandled exception that nobody had planned for. In safety-critical code, that is the worst possible outcome.
Why the Standard Avoids Exceptions
Bjarne Stroustrup, the creator of C++, is a strong supporter of modern C++ exception handling, and exceptions are fairly inexpensive. The JSF standard excludes them mainly because of the maturity of tooling at the time. Stroustrup has explained the reasoning: JSF++ is intended for hard real-time and safety-critical applications, such as flight control software. If a computation takes too long, someone may die, so response times must be guaranteed. With the tool support available at the time, exceptions could not be guaranteed in that way. The JSF standard also simulates exceptions, preparing for a time when tooling is capable of handling them.
Locating the Unhandled Exception
The fix begins with the density altitude calculation, which is where the unhandled exception was thrown. The non-compliant JSF version still carries the remove before flight tag, which is essential. The code, however, uses several keywords that the JSF standard does not allow. Under AV rule 208, which prohibits exception handling, the try and catch blocks with std::exception are not allowed, and neither is the throw statement.
Returning Error Codes
The compliant version handles errors with return codes instead of exceptions. An exception must be handled by a proper exception handler, but a return code passes the handling responsibility to the calling function. In the density altitude calculation, the return code is set to different values depending on what happens during the calculation. The calling function receives that code and decides how to respond, rather than the entire program failing and breaking.
Testing the Fix
With the fixed code in place, the aircraft flies safely again. Cycling through the MFD values and checking the density altitude calculations shows that no unhandled exceptions are generated. If a returned value misses its calculation time or comes back completely empty, the program still continues, because it returns an error code rather than throwing an exception that crashes the program. Flying and talking at the same time is difficult, but the demonstration is a success.
Recursion Is Restricted
The second major area in the flight code is AV rule 119, which states that no function may directly or indirectly invoke itself. In other words, recursion is not allowed. Recursion is an appealing technique, and it is fairly common among programmers who enjoy it. Its main problem in safety-critical code is that it exposes the program to the possibility of stack overflows.
Unbounded Stack Growth
Each function call sets up a new stack frame. With recursion, frame after frame is created, and each new function invocation is added to the stack. The difficulty is that the maximum recursion depth is often unknown in advance. That uncertainty is a major problem in safety-critical applications, which is why recursion is prohibited.
Why Recursion Needs a Known Depth Bound
Safety-critical applications need to know the maximum amount of memory a program will use. Recursion makes that difficult. Each call to a function sets up a new stack frame, so a recursive function stacks frame after frame onto the call stack. Because the maximum recursion depth is often unknown in advance, the stack can overflow. That risk is a serious problem in systems where memory use must have a known upper bound.
Rewriting the Binomial Coefficient Iteratively
To make the C++ flight calculator JSF compliant, the recursive calls must be removed. The flight calculator uses a binomial coefficient function to compute alternative airports for the flight plan. In the original definition, the function calls itself twice: once for the case of n minus one and k minus one, and again for the case of n minus one and k. Both calls are recursive, and neither has a known maximum depth, which opens the program to running out of memory.
The compliant version replaces the recursion with an iterative approach. The function declaration remains, but the body no longer invokes itself. Iterative code is usually less elegant than recursive code, and this version is longer and arguably less pleasant to read. It is, however, JSF compliant.
Memory Allocation Rule AV 206
With exception handling and recursion addressed, the next requirement to remove is dynamic memory allocation, which is probably the most important one. AV Rule 206 states that neither memory allocation nor memory deallocation may occur after initialization. In practice, a program must not allocate any memory while it is actively executing.
Why Dynamic Allocation Is Restricted
The rule exists for two main reasons. First, dynamic allocation introduces unpredictability. The time it takes the memory manager to find available memory for newly allocated data cannot be known in advance. Second, there is no guarantee that enough memory is available for a new allocation at all.
Allocating memory also places data on the heap, which can cause fragmentation. As more data is allocated, the heap splinters into small, unusable chunks. A new allocation that is large may then fail to fit anywhere, even when the total free memory appears sufficient.
The Dynamic IAS History Buffer
The non-compliant C++ code stores the history of indicated airspeed, or IAS, data, which is used to calculate gusts. The problematic line creates a unique pointer and returns it to the history buffer variable. This dynamically allocates new memory on the heap, which violates the JSF standard.
Using a Fixed Maximum Size
Several fixes are possible, but the chosen approach is to hardcode a maximum data size for the IAS history array. A constant named max IAS history defines this size and is used when the data is initialized. All of the available indices in the data array can then be used, and the exact maximum size is known before the program runs. Nothing needs to be allocated dynamically, and the calculations can still be performed on the array. This eliminates the dynamic unknowns.
Cyclomatic Complexity and AV Rule 3
As a bonus, AV Rule 3 states that the cyclomatic complexity of a function shall not be greater than 20. Cyclomatic complexity measures how many decision paths exist inside a function. Each if statement, while loop, for loop, and boolean operator such as and or or, as well as each switch statement, adds to the total. The count for a function is the sum of these decision points.
Counting Decision Points in the Iterative Function
A hands-on example makes this clearer. Consider the iterative version of the binomial coefficient function. The function declaration itself counts as one point toward cyclomatic complexity. Each if statement adds another point, and the or statement in the condition adds one more. The function contains a few more decision points, and its for loop adds to the total as well. The combined count for the entire function must remain below 20.
A Flight Simulation Interlude
Meanwhile, the aircraft flies without trouble, and the pilot in the simulation feels confident enough to fly with a calm mind, even with the plugins running on the multifunction display. The pilot then feels a need for speed and wishes for missiles. A moment later the pilot calls out a pull-up warning and an emergency, then recovers from it. The pilot wants to dip a wing into the water and tells themself they can do it and just need to slow down. A wall appears, but it turns out to be a highway, and dipping wings into a highway is not recommended.
NASA's F Prime Standard
The principles of the JSF C++ standard have spread well beyond the standard itself, and their influence appears in many other fields and standards. NASA's F Prime is its own standard for flight software, and it was also made publicly available, in 2017. Readers familiar with JSF will recognize its approach. F Prime prohibits dynamic memory allocation, exception handling, and recursion, which makes it a sister standard to JSF.
Influence on the Automotive Industry
Coding standards for C++ are not limited to aerospace. Automotive software also uses them, including MISRA and AUTOSAR, where AUTOSAR stands for AUTomotive Open System ARchitecture. AUTOSAR references JSF by name as one of the influences on its C++14 standard. Because AUTOSAR belongs to a more modern version of C++, it offers benefits and capabilities that the older JSF standard lacked. For example, smart pointers are allowed under AUTOSAR.
Modern cars are essentially computers on wheels, so their software depends heavily on these standards. Major automakers, including BMW, Ford, Toyota, and most other large manufacturers, rely on AUTOSAR. Notably, the language safety practices in this automotive work trace back to a decision made by the Pentagon decades ago.
Should You Follow the JSF Standard Today?
The code now runs, the systems indicate normal operation, and the program follows the JSF C++ standard. A fighter pilot-style program has been written successfully. The real question is whether JSF should be followed in modern C++ code.
Bjarne Stroustrup, the creator of C++, offers a twist. Although he was on the committee that formulated the JSF standard, he would advise using the C++ Core Guidelines today. Modern C++ has continued to evolve over the past twenty years rather than staying the same, so the guidelines reflect current practice. The JSF standard was a remarkable engineering achievement for its time, but newer, modern safe C++ is the better choice now. The JSF standard is still worth studying because it is an important and interesting part of history. It turned a complex language into something predictable enough for critical infrastructure. Safe software is not only about being the smartest programmer in the room. It is also about the discipline of knowing what aspects to remove before flight. Lori wired out.
Turn your watchlist into a reading routine
Bring your YouTube videos together, read summaries with key passages marked, and explore the full transcript. Save your own highlights with Pro.
Start with 5 free batteries. Each covers up to 30 minutes of a new summary.
New summaries depend on video availability and demand; processing may take time or require retry.