Yugos used Commodore Basic
February 4, 2009 9:11 PM   Subscribe

"The avionics system in the F-22 Raptor, the current U.S. Air Force frontline jet fighter, consists of about 1.7 million lines of software code. The F-35 Joint Strike Fighter...about 5.7 million lines of code...Boeing’s new 787 Dreamliner...about 6.5 million lines of software code. These are impressive amounts of software, yet if you bought a premium-class automobile recently, it probably contains close to 100 million lines of software code."
posted by mr_crash_davis mark II: Jazz Odyssey (63 comments total) 8 users marked this as a favorite
 
design patterns- people. design patterns!
posted by localhuman at 9:14 PM on February 4, 2009


It seems like most American cars only have five lines.

10 Consume fuel
20 Refuse to innovate
30 Putter about
40 Goto 10
50 Invest in R&D, improve fuel efficiency and reduce emissions, retrain workforce, keep executive compensation reasonable, prepare for 21st century.
posted by allen.spaulding at 9:16 PM on February 4, 2009 [27 favorites]


Given how much redundancy and general safety has to be built into avionic systems, I'm impressed with how little code planes use, and equally disgusted with how much bloat that cars carry. If a luxury brand can't get it right, I'm not surprised the automobile industry is in trouble.
posted by Blazecock Pileon at 9:19 PM on February 4, 2009 [1 favorite]


Worth noting that the microprocessors used in cars are microcontrollers, which are microprocessors with onboard program storage, memory, glue logic and peripherals (analog/digital converters, timers, etc). They're usually 8 bit, operate between 2-16mhz, and the midrange to highend ones are a little less powerful than the CPUs in mid-late 80s personal computers, but more powerful than an Apple II or C64. Nothing even close to as complex as the CPU in your desktop. And the reason there's so much code is that there are hundreds of these microcontrollers, each dedicated to a single task or a few closely related tasks. I would imagine that the electronics in military aircraft are more centralized and streamlined.
posted by DecemberBoy at 9:24 PM on February 4, 2009 [1 favorite]


Pffft... my car contains several hundred million lines of code.

Oh, you mean when I take out my laptop and USB drives? Oh...
posted by jkaczor at 9:24 PM on February 4, 2009


I'd feell better if it was all distilled down into a one-line lamba function.
posted by H. Roark at 9:28 PM on February 4, 2009 [5 favorites]


What's the bet that most of that is filler? It's like the Twelve Stations of the Cross. "Boss, we can only come up with ten." "Yeah, I dunno, maybe have him fall down a couple more times."

I bet that with a certain combo of button presses on the control stick, a Raptor pilot could get a game of Tetris happening on the HUD.
posted by turgid dahlia at 9:28 PM on February 4, 2009 [2 favorites]


Cloud commuting?
posted by acro at 9:32 PM on February 4, 2009


So if we run the bloatware removal tool on our cars, we can get 35 mpg?
posted by netbros at 9:35 PM on February 4, 2009


OK, dozens of microprocessors, hundreds of inputs, blah blah blah = 100 million lines of code? This smells remarkably like the little signs that went up on my local fuel pumps when gas was $4 per gallon telling me that high credit card rates were what was making my gas so expensive.

I mean so I'm going down the road at 40 mph. Suddenly my bumper registers an impact. Does it really query my oxygen sensor and see whether or not my fuel injectors are fouled so that it can decide to say, "What, he skipped the 70,000 mile tune up? Fuck him!"

I'm going to need to see some of this code, presented by someone who describes it as software or code but not both at the same time, before I buy this.
posted by Kid Charlemagne at 9:40 PM on February 4, 2009 [5 favorites]


My bicycle has 0 lines of code! And thus I am smug.

...my back brakes are not working. Maybe I shouldn't gloat.
posted by Lemurrhea at 9:41 PM on February 4, 2009


Maybe I shouldn't gloat.

Gloatware, right?
posted by turgid dahlia at 9:42 PM on February 4, 2009


My bicycle has 0 lines of code! And thus I am smug.

...my back brakes are not working. Maybe I shouldn't gloat.


Have you tried rebooting?
posted by nasreddin at 9:45 PM on February 4, 2009 [2 favorites]


Doesn't really surprise me. Cars don't have a 'central computer' as such; they instead have a lot of purpose-built systems, each working quasi-independently to do whatever they're tasked with. There's probably quite a bit of code redundancy involved. At least in some cases I'd bet that there are micros with more identical lines of code than unique ones.

But by using microcontrollers rather than a more centralized system, it's probably a hell of a lot easier to test and QA, and easier to reuse one component in a new model without much re-engineering. I doubt you'd really want a car with an entertainment system designed, tested, and QAed like the avionics of the F-22: it would probably have a pricetag that wasn't too dissimilar.

You may want certain parts of your car's electronics to be held to that standard (the engine control unit, the ABS computer, etc.), but not other parts. And once the critical systems are designed and tested out extensively, it makes sense to use them, unchanged if possible, in as many different vehicles as possible.
posted by Kadin2048 at 9:52 PM on February 4, 2009 [5 favorites]


nasreddin: maybe reshoeing instead?
posted by Popular Ethics at 9:52 PM on February 4, 2009


100 million lines of code? Let's say there are 100 microcontrollers. Most of these are 8-bit MCUs with a maximum of 64KB of memory space. It is difficult to believe that there are 100 microcontrollers with an average of 1 million lines of code. Sounds like BS.
posted by JackFlash at 9:54 PM on February 4, 2009 [2 favorites]


I'm pretty leery of that number, unless they're talking about lines of assembly code, or the total amount of software that one car manufacturer maintains, or something.

They talk about a hundred chips being on cars, but I guarantee you that the overwhelming majority of them are very cheap and have less than 64K of ROM, which means good luck fitting a hundred thousand lines of code on each of them! But even if you did that only accounts for 10% of the claimed code!

And making fifteen copies of Nucleus RTOS, or whatever, doesn't count.
posted by aubilenon at 9:55 PM on February 4, 2009


design patterns- people. design patterns!

Copy, paste, and edit is a pattern.
posted by flaterik at 9:58 PM on February 4, 2009


design patterns- people. design patterns!

How would design patterns reduce lines of code?

Given how much redundancy and general safety has to be built into avionic systems, I'm impressed with how little code planes use,

Huh why? The more careful you have to be about the code, the less code you write.


and equally disgusted with how much bloat that cars carry. If a luxury brand can't get it right, I'm not surprised the automobile industry is in trouble.

Why would you get upset about that? It's not like "lines of code" have some physical weight or something on the car. I'm sure the mission critical stuff is much more thoroughly tested then, like, the DVD navigation system.
posted by delmoi at 9:58 PM on February 4, 2009


I think the article is playing fast and loose with the stats.

Note that it says: "The avionics system in the F-22 Raptor ... consists of about 1.7 million lines of software code." (emphasis mine)

Avionics is a small-but-important part of what a fighter jet does. When the article talks about avionics, I'm guessing they're not including things like engine control, control surfaces, fire-control radars, weapons systems, electronic counter-measures, etc.
posted by Cool Papa Bell at 10:00 PM on February 4, 2009


I'm sure the vast majority of the "100 million lines of code" is in the UI the nav and multimedia system. Vista has 50 million lines of code. It's probably a bunch of common libraries thrown together with some simple glue logic and UI. The actual code developed in-house would be just a few thousand lines.
posted by delmoi at 10:01 PM on February 4, 2009 [2 favorites]


Popular Ethics: maybe reshoeing instead?

You're thinking of horses.
posted by zamboni at 10:07 PM on February 4, 2009


These numbers are meaningless. What language? How is this measured? 100 lines of C isnt equal to 100 lines of assembly.

What a car does is 100% different from what an airplane does. They have different systems and different standards. There might be a lot of logic in figuring out when to put the car in "limp mode" when a sensor or two give odd readings. There's no such logic in a plane. The designers of the plane left those decisions up to the pilots, and rightfully so.

Cars cant be built on a monolithic system in charge of everything. There's a need for redundancy and cheaper parts because no one would be able to afford service on them if they were built like jets. Airlines and the military are constantly working on their machines. They have expensive and elaborate maintenance schedules. They have teams of people per plane. Ive owned cars that needed nothing more than gas and oil for years. Apples and Oranges.

A fighter jet doesnt really have airbags, abs brakes, dumbed down controls (which require more logic on the backed), emissions requirements, etc. At least on the level of a car.

A car is a device piloted by the lowest common denominator. It cant be a specialist device that relies on the expertise of the pilot to deal with emergencies and odd situations. Youre pretty removed from how it works and thats gonna cost you in complexity.
posted by damn dirty ape at 10:12 PM on February 4, 2009 [2 favorites]


function dreamliner_toilet;
//
// V1.425 - Boeing Inc.
//
if (toilethandle = WM_FLUSH) then
  begin
    try
      if not ERR_CLOGGED then execute_flush;
    finally
      if ERR_HUMAN_SUCKED_OUT then cockpit_alarm(WM_FLUSH);
    end;
  end;
posted by crapmatic at 10:17 PM on February 4, 2009 [5 favorites]


function dreamliner_toilet;
...
posted by crapmatic

You know what I'm sayin'.
posted by davejay at 10:26 PM on February 4, 2009


It's not like "lines of code" have some physical weight or something on the car.

If you had the choice of maintaining one million lines of code, or a million, and your job and reputation rested on shipping a reliable product, which would you choose?
posted by Blazecock Pileon at 10:35 PM on February 4, 2009


I'd choose one million over a million any day.
posted by freebird at 10:49 PM on February 4, 2009 [5 favorites]


Me two. I actually meant a hundred million, but it didn't come out right. Apologies.
posted by Blazecock Pileon at 10:52 PM on February 4, 2009


A large part has to do with quality control. The government has fairly strict standards on what they want tested, and how they want it tested. Fortify is a great tool, and also a mandate for passing QA. Considering that Fortify does branch testing, you tend to keep your code tight as possible to avoid the 15 (literal) years it would take for a complete crawl.

Kolmogorov had some interesting things to say about the subject matter.
posted by The Power Nap at 10:58 PM on February 4, 2009


Me two million.
posted by metaplectic at 10:59 PM on February 4, 2009 [1 favorite]


design patterns- people. design patterns!

WTF, now I have 1.7 million classes!
posted by Artw at 11:09 PM on February 4, 2009 [1 favorite]


Prius owners, try this:
While the car is on, simultaneously push in the foot brake, seatbelt release, and power button to turn it off. On my 2005 Prius it doesn't register the power button, though the dash lights for parking brake and no-seatbelt come on immediately. I assume the power button shares an interrupt, perhaps with the parking brake.

This gets me all the time if I pull in to a parking spot in a hurry to get out and go somewhere. I push down the brake, hit the power button with my right hand, release the seat belt with my left hand... then wait... and hit the power button again.

Makes me want to see and/or rewrite some of that code. I mean, how long can that interrupt service routine be?
posted by bigtex at 11:09 PM on February 4, 2009 [2 favorites]


It's like the Twelve Stations of the Cross.

Looks like they added a couple since last year's model. Bloat!
posted by wemayfreeze at 11:36 PM on February 4, 2009


100 million is just a fantasy. That's 100 thousand programmer-years (yes, your average programmer writes about 1000 lines of production code a year.)

The cost of code bloat is tremendous. If code gets large enough, it's literally impossible to make coherent changes...
posted by lupus_yonderboy at 12:00 AM on February 5, 2009


ECUs embedded in the body, doors, dash, roof, trunk, seats, and just about anywhere else the car’s designers can think to put them

How do all those processors communicate, and get power? Is there some kind of central data/power bus running through the entire vehicle, to every nook and cranny that has one of them?
posted by woodblock100 at 12:49 AM on February 5, 2009


Absence of code does not necessarily correlate with lack of complexity. A lot of Level A flight control systems are designed, implemented, and tested using development environments such as SCADE, or something similar.

With SCADE, a lot of the implementation is done graphically. Look at the example on the Wikipedia article. As a software developer, I can appreciate how much complexity that pretty picture is abstracting away. My guess is that the thousands of lines of code that that picture represents wouldn't count towards the SLOC metric.

Also, any comparison of software systems based solely on lines of source code is crap.
posted by veedubya at 1:05 AM on February 5, 2009


I know that the engine controller in the Nissan 370z has about 1.5 megs of compiled binary, most of which is from code generated by graphical tools.

woodblock100: I think a lot of this stuff doesn't need to communicate much. Your windshield wipers don't have anything to say to your airbag deployment system, your auto-dimming rear-view mirror, or your anti-lock brake system. The ones that do probably have a real simple bus like I2C or some similar serial protocol.
posted by aubilenon at 1:57 AM on February 5, 2009


100 million lines as a figure is kind of frightening. What are the chances that code is 100% perfect and free of bugs? Because even if 99.999% of it is bug-free, that would still be 1000 lines of shitty code on your device that is hurtling you through space at 120km/h. Frightening.
posted by tehloki at 2:03 AM on February 5, 2009


Is there some kind of central data/power bus running through the entire vehicle, to every nook and cranny?

Yup. The more complicated systems like the engine computer, anti-theft, and climate control talk to each other over CAN. Smaller things, like the little light in the trunk, probably sit on a LIN bus.

In new cars, you can access the CAN bus in through the OBD-II port. Hobbyists have reverse engineered the protocols for some vehicles. In particular, I've heard that you can get software that allows a laptop to control nearly every system in a C5 Corvette. You can do some very low-level stuff like blink the trunk light even when the trunk is closed or command the speedometer to display 65 mph while parked.
posted by ryanrs at 2:03 AM on February 5, 2009


This is just the new trend of evaluating automobiles with the lines-of-code per gallon metric.

Lines-of-code per gallon is a much better measure of performance. Still working on lines-of-code per cups of coffee.
posted by twoleftfeet at 2:25 AM on February 5, 2009


Consider:

1. US automakers get a lot of small parts from a lot of different companies. (A friend of mine worked at a company who's sole purpose was to make chips and code to control speedometers.)
2. Each bit, from different companies may have it's own set of code - no standardization between them.
3. Extra stuff like having the interior lights turn on slow, or fast, or turn off slow, or fast, based on a number of other conditions ("light switch?" "Door open?" etc.) means that someone has to code reading data from other bits in different code- oh look, now we're translating between bits.
4. "Now let's add GPS!" "Now let's add iPod plug in!" "Now let's add Satellite Radio!" "Now let's add cell phone plug-in!" "Now let's add night vision!" "Now let's add motion sensors in the back!" etc.

Now consider most military or commercial airline stuff- they just have to do the job. They don't have to have "nice" touches like slow lighting, audio drop off, a "smooth" ride on dials and a billion other things that people consider luxury. Odds are, the parts are from a (comparatively) small group of companies. Add in the fact that these things only see upgrades about every 5 years or so, not on a yearly basis, so it's easier to stick with code from before.

Yeah, I can totally see cars outpacing everything else in code.
posted by yeloson at 3:09 AM on February 5, 2009


it's only a matter of time before double life will be reality.
who needs a playstation when you can bring down an actual jet?
posted by krautland at 4:03 AM on February 5, 2009


Note the words "Premium Class".

Have you seen things like (blech) iDrive on the 7 and 5 series BMW? There's a stupid amount of code right there. We're not talking a baseline Honda Civic here. These are cars that do lights shows when you turn them on, have multiple setting traction controls and shift controls, launch control, etc.
posted by eriko at 4:23 AM on February 5, 2009


eriko: it shall please you to know chris bangle has been fired from bmw.
posted by krautland at 4:30 AM on February 5, 2009


The IEEE uses the term "software code"? From now on, I'm going to say "light emitting LEDs" (or "LED diode") to my EE boss.
posted by DU at 4:30 AM on February 5, 2009 [1 favorite]


there was a nice article in fast company on the space shuttles' software engineering team:
This software never crashes. It never needs to be re-booted. This software is bug-free. It is perfect, as perfect as human beings have achieved. Consider these stats : the last three versions of the program -- each 420,000 lines long-had just one error each. The last 11 versions of this software had a total of 17 errors. Commercial programs of equivalent complexity would have 5,000 errors.

This software is the work of 260 women and men based in an anonymous office building across the street from the Johnson Space Center in Clear Lake, Texas, southeast of Houston. They work for the "on-board shuttle group," a branch of Lockheed Martin Corps space mission systems division, and their prowess is world renowned: the shuttle software group is one of just four outfits in the world to win the coveted Level 5 ranking of the federal governments Software Engineering Institute (SEI) a measure of the sophistication and reliability of the way they do their work. In fact, the SEI based it standards in part from watching the on-board shuttle group do its work.

The group writes software this good because that's how good it has to be. Every time it fires up the shuttle, their software is controlling a $4 billion piece of equipment, the lives of a half-dozen astronauts, and the dreams of the nation. Even the smallest error in space can have enormous consequences: the orbiting space shuttle travels at 17,500 miles per hour; a bug that causes a timing problem of just two-thirds of a second puts the space shuttle three miles off course.

NASA knows how good the software has to be. Before every flight, Ted Keller, the senior technical manager of the on-board shuttle group, flies to Florida where he signs a document certifying that the software will not endanger the shuttle. If Keller can't go, a formal line of succession dictates who can sign in his place...
which i guess is about to be disbanded?
posted by kliuless at 4:32 AM on February 5, 2009 [4 favorites]


These numbers don't look right to me, either. I'm curious as to which version of the F-35 they took the 5.7 million number from - I'm guessing that the F-35B STOVL Variant has a far more complex control system than that on the F-35C Carrier Variant, and the F-35C more complex than the F-35A CTOL Variant. (F-35 Variants).
posted by Nice Guy Mike at 5:02 AM on February 5, 2009


I still have to question whether a lot of this uses any code at all. I mean, ok there example given of a lights that dim over time rather than instantly when the door is closed. How much of that is really written code and how much of that is physical logic?

Are there special car logic chips that run on 12/14.5 volts or is the another 10% of the sticker price a couple thousand darlington arrays?
posted by Kid Charlemagne at 5:30 AM on February 5, 2009


'86 Buick Century: 0 lines of code!
posted by Mister_A at 5:32 AM on February 5, 2009


Aircraft software certification is a huge pain in the ass at the higher cert levels. It behooves you to write efficient code to save time in testing and code coverage.

Something the management at my old job (avionics) never got was that testing takes time. They would promise our customers quick turnarounds for minor software fixes which turned into logistical nightmares for us systems guys.

There was one week where management promised a fix to a bug on Friday to be completed by Monday. It was something really simple - the fuel display wasn't changing colors at the right values or something like that. Anyway, the software guy fixed three lines of code, made four or five builds (a different one for each aircraft, of course), made copies, and was home in time for dinner on Friday. We had four systems engineers working 24 hours a day all weekend in order to test the code and write up the documentation by Monday morning.

Remember kids, the bulk of the effort is never writing the code. It's all the testing and certification work associated with it.
posted by backseatpilot at 5:45 AM on February 5, 2009 [5 favorites]


100 million lines of code to solve the problems of Travelling Salesmen?
posted by benzenedream at 5:54 AM on February 5, 2009


I used to subscribe to the ACM Risks magazine. I seem to remember reading about someone testing an early computer controlled fighter (F18?). He pressed the button to raise the landing gear while in a hanger. This resulted in the engineers adding a new function call... "IfWeightOnWheels". Probably apocryphal, but funny.
posted by cosmac at 6:47 AM on February 5, 2009 [1 favorite]


Amen to that, backseatpilot! And sadly, quality control and especially testing often are the first things to out of the window when sizing down projects... until they run into real trouble.
posted by Glow Bucket at 6:47 AM on February 5, 2009


When you start up a Prius, it feels like it's booting up when the logo appears on the screen.

I reluctantly had to get rid of my Prius because I was having major problems with the 12v system. I was on my second battery (the little starter battery, not the hybrid battery) in two years. Either it wasn't charging properly or something was draining it, but near the end I had to jump start it several times a week.

When the 12v battery in a Prius is dead, the car is really totally dead. You can't open the door without using the tiny physical key hidden in the key fob and you can't even open the trunk (where the battery is), so they thoughtfully provide dedicated battery charging terminals under the hood. When it powers up after a dead 12v battery, you'll often see error messages such as parking brake failure.
posted by mike3k at 7:48 AM on February 5, 2009 [1 favorite]


A friend from college worked at a company doing coding for fighter jets and the like and everything was, by law, done in Ada, I believe. I kind of doubt that commercial carmakers use the same language, so as many have mentioned, we're not comparing apples to apples.
posted by mikeh at 8:16 AM on February 5, 2009


cosmac sez:
I used to subscribe to the ACM Risks magazine. I seem to remember reading about someone testing an early computer controlled fighter (F18?). He pressed the button to raise the landing gear while in a hanger. This resulted in the engineers adding a new function call... "IfWeightOnWheels". Probably apocryphal, but funny.


That's the RISKS Digest, and the article you're probably thinking of is here (summary: it's from 1986, it was on an F-16, and is a "friend of mine who wrote some of the F-16 code told me..." story). One responder to that article is rather skeptical.
posted by doorsnake at 11:06 AM on February 5, 2009 [1 favorite]


Over ten years ago I worked on a project that communicated with the Corvette vehicle network (then ALDL). The test system I worked on had the capability of resetting the odometer if it read less the 50 miles. I was instructed to take the car (a nice red one) from CCO (Chevy Central Office) at the GM Tech Center to the Service Research Center and drive home for the evening. That evening's assignment was to drive the Corvette until it had 49 miles on the odo, use the tool to reset to 0, and drive to work the next day.
That evening a big white Cadillac started to make a left turn right into my path as I was driving the 'vette. I swerved the car over to the extreme right lane and back in a single motion, eliciting a "whew!" sound from my wife.
The remainder of the evening was uneventful.

P.S. The code was C and later converted to assembler to conserve space in the 8K (!) EEPROM memory.
posted by Drasher at 11:45 AM on February 5, 2009


Fondly remembering my first used car. A 1937 Ford that I paid $25 for. A floor stick shift that I had to really lean on to keep it from jumping out of reverse. Of course if it had all this code stuff it probably wouldn't have jumped out of reverse. But then I doubt I could have afforded the $50 it would likely have cost.
posted by notreally at 12:05 PM on February 5, 2009


This bit is redolent of bullshit:
Last year I bought a new car and was staggered to discover a 500-page manual explaining its operations, along with a 200-page companion manual for the GPS and radio systems.
Wha-huh? Curious how he doesn't give the make and model. is that the sort of manual that includes the same instructions over and over in different languages? I thought that the idea with pricey cars is that you didn't need so many instructions because the car took care of it for you.
posted by Halloween Jack at 2:59 PM on February 5, 2009


Halloween Jack This bit is redolent of bullshit (...)

two seconds with professor google could have netted you a recent BMW 5-series manual. here's a pdf download - it's nine mb and 294 pages. not included in the pdf but also part of what you get with your car: Telephone Users Manual, Listing of Voice Commands, iDrive Menu Hierarchy List and a bunch more.

I don't find his assertion of a 500-page manual difficult to believe at all.
posted by krautland at 4:12 PM on February 5, 2009


All the chips in my car are in the paintwork...
posted by pompomtom at 4:16 PM on February 5, 2009


All of this crap only makes the cars harder to repair after a few years and, ultimately, it is more environmentally-friendly to keep a car running for as long as possible. I learned this the hard way in my 1993 Nissan Altima. There were at least two computerized modules for the power windows that got fried and had to be replaced at great expense. The master switch had a microprocessor that was likely more powerful than the computer in the lunar module.
posted by drstrangelove at 6:45 PM on February 5, 2009


If you had the choice of maintaining one million lines of code, or a million, and your job and reputation rested on shipping a reliable product, which would you choose?

Software doesn't need to be maintained like a toilet or a house. Software maintenance is mostly about upgrading existing programs with new features. But if you don't need any new features, if your software is "done" then it's done forever and never needs to be changed. 10 million lines of old, well-tested, well-worn code will be much easier to maintain then 1 million or even 100,000 lines of new code.

No one sits down and writes 100 million lines of code for a new project. The vast bulk of that code is going to be old libraries, the OS, etc which probably work well enough for the car (Like I said, I bet the vast majority is probably superfluous UI crap).

The computer I'm using now, and yours as well I'm sure probably has about 100 million lines of code on it. How much time do you spend 'maintaining' it? Why would a car maker using the exact same software as an OS for their dvd-nav system need to spend any more time when all they're using it for is to run their own nav application?
posted by delmoi at 10:32 AM on February 6, 2009


« Older No leather, but lots of lace   |   Tips from the Black Metal Martha Stewart Newer »


This thread has been archived and is closed to new comments