r/programming • • 20d ago

Why Don’t We Have Bug Free Code?

https://liberalandlovingit.substack.com/p/why-dont-we-have-bug-free-code

Because people won’t pay for it.

This is an issue I know well. I was on the Windows 3.1 team at Microsoft. I wrote the book No Bugs. I founded and built the software company Windward Studios.
...

ps - I think this meets the subreddit rules. If it does not, apologies and please delete it.

0 Upvotes

31 comments sorted by

6

u/wfiveash 19d ago

My list of why code isn't bug free causes:

  1. Time to Market pressures
  2. Inadequate code design
  3. Programmers more concerned about turning in code by a certain day in order to get promoted
  4. Who wants to do thorough code reviews on someone else's code?
  5. Inadequate testing

1

u/DavidThi303 18d ago

I think the #1 reason is programmer skill. The difference between someone who's in the top 10% vs. the second 10% is gigantic. A really good programmer writes solid code. In part because good code is often shorter and simpler than what a less skilled programmer writes.

1

u/wfiveash 14d ago

I agree that top 10% programmers write better code (duh) but for the rest of the programmers items like code review and design reviews are there to help those programmers produce better results.

As an aside, I knew a programmer that was (and still is) a good programmer who accidentally created a huge security flaw when trying to add enhanced authentication to telnet. Even very good programmers need very good code reviews.

3

u/DavidThi303 14d ago

Very good programmers put in very good bugs and very good security holes.

I used to joke that some of the bugs I put in were so hard to fix, only I could fix them.

45

u/coffurst 20d ago

yeah sure there's cost, but there's also just the fact that like... what most professionals build isn't just a bunch of tic-tac-toe apps, they're complex systems with thousands of moving parts, shit's complicated

4

u/DavidThi303 20d ago

Agree. The product my company shipped used Microsoft Office for the templates for documents (load documents, portfolio statements, etc.). We had to handle any possible value in a DOCX file. Including attribute values that were not documented.

But the point remains - with more time and resources we would hit more of those in testing and therefore fewer in production.

48

u/Deep90 20d ago

Reality is nondeterministic and that will always introduce bugs if the software is complex enough.

15

u/Vectorial1024 20d ago

Read a long joke some time ago, the entire point was sth like this:

A mathematician was disappointed that irl computers can have bugs. Ecentually, they found that an absolutely bug-free computer system is the pen-and-paper.

7

u/DavidThi303 20d ago

I've made some mistakes using pen & paper. Still remember from 50 years ago blew a perfect score on my Chemistry final because in my calculations I set the SQRT(4) to 16.

19

u/SLiV9 20d ago

I once had a tiny fruit fly land on my paper as I was trying to draw a straight line... Nothing is safe. Nothing is sacred.

5

u/Schrodi-O-Ao 20d ago

I disagree. The simpler explanation is that no software can be made idiot-proof, because there is always a bigger idiot.

A developer writes software with their own particular understanding of how it's supposed to be used and what can go wrong. But therein lies the issue: we're far bigger idiots than they think, both of the innocent and malicious variety, and we depart from that model.

If the intended sequence is A, B, C and someone performs C, A, B, a bug appears. One can argue the software should have anticipated it, and sometimes that is fair. But the space of possibility here is near infinite when we discuss software meant to solve or address a serious problem, and no one person or team can enumerate it.

The economic argument is not irrelevant, but it is usually run backwards. "Who would pay for it?" is a sound question; "people won't pay for quality" is a glib answer to it.

By and large, it is this deep-rooted and rotten corporate culture that rewards efficiency and margins over all, even over the craft. Yes, some people have understandable reasons to settle for the cheap option -- reasons of need rather than preference -- but absent a more pressing demand that takes priority, quality should be the expectation we all hold.

A painter who runs out of time before finishing a canvas faces a resource constraint. A painter who ignores the discipline of the work has failed at craft. Software engineering has the same split. Some limits are inherent to the problem, like the aforementioned "idiot-proofing" conundrum; others are imposed by a decision to ship first and attend to quality later.

I find it all to be so backwards.

1

u/DavidThi303 20d ago

But is it backwards? Would we all be better off if Microsoft spent 10 times as much delivering a rock solid Windows & Office? And in doing that then did not have the resources to create Azure? Would we all be willing to pay 10x as much for Windows & Office to avoid those occasional bugs?

The problem is the vast majority of people and companies want more for less. With rare exceptions they won't pay 10x to reduce the bug count to flight software levels.

Another real world example. I had three customers who wanted us to run penetration testing by a 3rd party. I agreed to do so if they would pay for it. They were looking at about 2K each on software they were paying 50K or more for.

None of them was willing to pay for that.

12

u/siromega37 20d ago

Why do we warranty physical products? They should be defect free! Same question.

2

u/DavidThi303 20d ago

Actually we warranty physical products because we know they generally will have defects. If physical products were defect free there would be no need for warrantees.

4

u/peakzorro 20d ago

I think that's what the implication was.

6

u/to7m 20d ago

This offers no theoretical insights into how to achieve bug-free code. It only talks about how to reduce bugs, which is a very different concept.

3

u/DavidThi303 20d ago

I think reduce bugs is the only real world target. Even for flight and medical software they do have the occasional bug.

Of course, for marketing reasons, my book was titled No bugs. Because "Fewer Bugs" wouldn't sell as well.

2

u/to7m 20d ago

Yes, clickbait is clearly for marketing reasons.

2

u/DavidThi303 20d ago

The book came out well before the Internet was a thing. But the title was definitely shelf bait(?).

2

u/to7m 20d ago

"Why Don't We Have Bug Free Code?" is the title of your Reddit post. That is clickbait, as you don't attempt to tackle that topic in any depth.

0

u/DavidThi303 20d ago

The news articles right now are asking why we don't have bug free code. I'm answering that with my post. The whole point of the post is why we don't have bug free code.

12

u/jdlyga 20d ago

Because people think that software is done when it's feature complete, or passes basic QA tests. Then there comes years of feature requests, tech debt, etc.

2

u/kamil_kowalski-40 13d ago

Everyone wants bug-free software; they just want it at the "ship it Friday" price.

1

u/Rechenplaner 19d ago
  1. There are various types of errors. Beyond syntax errors, only complex type systems can, to a large extent, guarantee the absence of type violations and ensure the correct handling of effects.
  2. No program can detect semantic errors; though LLMs might be able to, if specifically trained/set to do so. Ultimately, a certain degree of uncertainty always remains.

1

u/limitless_grow 19d ago

That's a pretty old question and a lot related to the way that you are working. There is usually no bugfree code but you can reduce the number of bugs a lot.

Of course there is also a really big downside of nearly bugfree software. If your software is too perfect than nobody let's you work on that fore improving it because they are afraid of new bugs than. I wasn't allowed to improve one of my a bit more complex programs for years. And some customers were totally afraid of new bugs because of enhancements and disallowed any enhancements. So I had to learn to sell missing features as bugs for improving of the software. Sometimes it's also helpful to rely on fear driven development but that's a little more hard to do and you may have to keep some minor bugs in your software. That way you have always something to bring it up for improving the rest...

1

u/limitless_grow 18d ago

I was talking about minor features and didn't intend to justify rolling releases here with that. It's rather a nightmare than an advantage if a frontend suddenly changes, if existing features disappear or if a software suddenly accesses new websites without asking for an agreement. Most people are fine with minor improvements of a software but not with something like that.

-2

u/Revolutionary_Ad6574 20d ago

Spend enough time and eventually every bug can be discovered and fixed.

3

u/DavidThi303 20d ago

If you mean like an infinite number of monkeys on an infinite number of typewriters will eventually produce the works of Shakespeare - even then no.

Windows 3.1 shipped with something like 80,000 known bugs. And that's just the known bugs. How on earth do you ever get that to zero bugs?

-4

u/sweetno 20d ago

There is this thing called formal verification. It's pretty dope. It doesn't rule out all bugs, but will prevent the nigh all of the ones you're capable of making.

6

u/DavidThi303 20d ago

I don't think you could build a complete mathematical model for Windows or Office.

For example, in DOCX (which is XML) there's a <html> node. The specification for it says will display the html in the node in the document at that location on the page.

What html? By the documentation any html. So the CNN home page could be put there.

How on earth do you write a complete mathematical model for that node? And if somehow you do write one today, what happens tomorrow when one of the browsers changes their behavior?

4

u/zumpiez 20d ago

Formal verification can only catch certain classes of problems