Subscribe to Martyr2's Programming Underground        RSS Feed

Can a Programmer Write the Perfect Program? Not Without The Help of Others.

Icon 12 Comments
On the Programming Underground we usually talk about code theory or examples, but once in awhile I like to pull up a seat and chat about some of my programming thoughts. Yeah most people think about dinner, going out with friends, picking the kids up on their way home but I am an unusual person, even by programmer standards. My day is often consumed with thoughts about how to write better code, seeing if statements in my chicken noodle soup, pondering the code already out there and writing my next project. So on today's episode, I would like to focus on an few thoughts I had recently about what it would take to have a perfectly working program. I am talking about a program that never fails or at least fails so rarely that when it happens you would be flabbergasted. I quickly realized it is impossible without the help from others and that is part of the problem. I dive into the topic on this episode of the Programming Underground!

<Bon Jovi's Livin on a Prayer... a programmer's prayer theme music>

Follow my logic here for a minute and assume that we want to make the perfect program. It is a tall feat for just a human to accomplish. We are prone to mistakes, it happens. However, what if we could code perfect and write all of OUR logic perfectly without error. Would that make it the perfect program? You may quickly say "Well of course, if we do not error, then how can it go wrong?"

I am here to argue that even if we learned everything we could and made not a single mistake, we would still have a program that is not perfect.. or at least has the potential of failing at no fault of our own. Why is that? Well, programs of any considerable size typically have to rely on something created by others. Whether that be a DLL written by someone else, an assembly, maybe a web service or web site, a file created by someone else etc. Even if that was all perfect we still have to run it on an OS that itself was written by others who are not perfect. The question arises "Can you build the perfect program on an imperfect system?" If you take that one step further, can that system be perfect if it is built on hardware that may not be perfect?

What I am trying to get at is that in order for you, the programmer, to create the absolutely perfect program we need help from all those before us right down to the hardware manufacturers. The higher we move up in abstraction, the more responsibility we have to take for other's imperfections. It is a bit of a downer to think like that, but it is true and I believe some companies, like Apple, realize this. To help "purify" their platform and try to fight against crashing systems and buggy sub programs, Apple fiercely protects some of its underlying function calls or strictly regulates who has access to the platform's guts. This is also a mechanism to protect their technology, trade secrets and suck the money out of others. But if only Apple can touch the guts, they can also implement the strictest protocols and standards to make sure mistakes don't happen often. Making anything they expose to application developers as rock solid as they can be and thus allow programmers to take responsibility for their own mistakes. If their application crashes, it is because they did something wrong, not some error from their OS.

So I think in order to build the perfect system I would have to control every aspect of the chain leading up to my program as well. I have to write that error handler to compensate for some .NET or Java class not working correctly and bringing down my program. Their class may have a problem because it relied on some underlying OS API call that failed which might have failed because of a hardware failure or some other person's mistake... or bad decision in implementation.

Now I don't expect you to go out and reinvent the wheel, but don't we all rely somehow on one another to do the right thing at their level in this chain? I think we should be asking for more accountability from those closer to the hardware (or the hardware manufacturers themselves) than having to take on a bunch of responsibility at the application level. Someone at a driver level should be held more accountable than someone who is writing an application when it comes to handling an error. The higher we go the more exponential the potential problems we have to keep track of. The less I have to worry about anticipating an error generated from another system, the more I can focus on my own errors.

But because we are all human, we all make mistakes. When the person at the driver level makes one mistake, the application developer may end up having to write code to protect against 5 different error scenarios.

I am just a bit tired of having to compensate for so many possible errors bubbling up from the depths of our machines. That is in addition to the ones I know I will make. If only we could go back in time with what we know now and redesign from the ground up. Then perhaps we would have finally reached that perfect program nirvana. We must do that sometime in the future because I don't think Star Trek runs on Windows!

Thanks for reading! :)

If you want more blog entries like this, check out the official blog over on The Coders Lexicon. There you will find more code, more guides and more resources for programmers of all skill levels!

12 Comments On This Entry

Page 1 of 1


27 May 2010 - 10:10 PM
Star Trek CLEARLY runs on Windows. ;)

V.C. Sniper 

28 May 2010 - 03:31 AM
int main()
return 0;

theres ur perfect program.


29 May 2010 - 10:07 AM
I think you missed the point a bit here Sniper. Yes, that may be the perfect program from a programmer's point of view, but you are relying on the compiler writers to have not made a mistake for compiling it and you are also relying on the OS writers to properly set aside resources to run it. Thus even for the simplest of programs we as application programmers can make at a lower language than say .NET or Java, you still assume people at the lower levels (closer to the hardware) have done their job. Your program may be perfect in its implementation, but in its execution by an OS you could still crash it (even though highly unlikely).

The point I was making is that in order for us to develop the highest quality mission critical apps, we are going to have to have a missing critical almost bugless support system to compile and run an application.

I also stated that my assumptions are more valid for applications that are "of any considerable size". The best we can do is write programs that do not rely on anyone's code, but how practical is that? No libraries, no extensions or DLLs, no direct API calls etc.

Thanks for the response. :)


29 May 2010 - 06:23 PM
Accountability should be there. The more I read about the experiences of developers like yourself who have been coding for many years, the more I realize I will end up implementing a lot of error checking and exception handling in the coming years. At this point in time this does not bother me, simply because I see it as an opprotunity to learn more about writing "error-proof" code (If there is such a thing). I can see where this would become frustrating though, and very quickly. I don't imagine there will ever be a 100% perfect enviornment to develop in. Like you said Martyr, we are human. I suppose the very least that people can do is give a crap about the systems they build, and hopefully we will see that when it comes time to code.

Good read Martyr.



29 May 2010 - 10:32 PM
You are right, there will never be a perfect environment... well, maybe not a perfect environment given our current state of tools etc. Perhaps we will eventually make something much more solid. I even think that is the reason behind all these "frameworks" lately. However, I think they have had the opposite effect in many situations.

Thanks for the reply alias! Glad to have your comments. :)


01 June 2010 - 09:54 AM
Similar to standing on the shoulders of giants, we must use what we have been given in order to advance and achieve; however, never assume that the giants are absolute.


02 June 2010 - 04:39 PM
Interesting article, I too agree that pretty much impossible to write a perfect program considering the underlying levels of software development. Also the majority of programs interactive in some means with external data, the implications of this are huge, take for example accessing a file hosted on a sever some place in Europe.

However I do think faults are a great thing to have, hypothetically if you could write every program perfectly which was complied by a coherent complier running on hardware that doesn't fail, would'nt it get boring? Personally I believe many programmers really enjoy problem solving, and then coming up with a solution to the problem, it's rewarding, it's nice when things work the first time and never fail, but to have that forever? No thanks.

I could go on, but I'm probably babling now :P


08 June 2010 - 04:48 PM
Just because you have a bug-free system for compiling, interpreting, and assembling at the low-level doesn't mean there won't be bugs, as there are still logic bugs that are the higher-level programmers' faults. Regardless of these bugs, programming still has lots of applications in the fields of Science, Technology, Engineering, and Math, including for new solutions. Just because we aren't solving the previos guy's problems doesn't mean we aren't solving somebody's problems, and I'm not just talking about buggy software.


07 September 2010 - 04:29 PM


Yeah most people think about dinner, going out with friends, picking the kids up on their way home but I am an unusual person, even by programmer standards. My day is often consumed with thoughts about how to write better code, seeing if statements in my chicken noodle soup, pondering the code already out there and writing my next project.

I thought this was funny, because I have always found myself in the same situation. I talked to a local computer science professor a few months ago (about an unrelated topic), and within the first session of talking to him, he told me "I bet you are the type of person who is constantly thinking about programming, and can't get a project off your mind until you reach a specific point in that program where that one bug is fixed etc."

When he said that, it really related to me. When you wrote that, it really really relates.

It's something in the way programmers think maybe - my step father is an audio / video technician, and although he is faced with bugs and things that could be pondered just like a programmer, he claims that once he leaves work, he leaves the pondering there - and doesn't think about current projects like a programmer would.


08 September 2010 - 09:30 PM
Thanks for the reply Splatocaster. Programmers are certainly their own breed when it comes to thinking about problems. I think it is the passion that drives us to always solve problems. The world definitely benefits from it though as we constantly push the envelope in developing new and exciting software products.



15 September 2010 - 06:00 AM
Hah! Just forget about the 'perfect' program. Think! can we write any program without the help of others?
The OS,IDEs and 100's of other tools we use, are made by others.


15 September 2010 - 09:54 AM
Yeah that was part of the point. The errors they make in the tools that we use also have an effect on the end quality of our programs. The flaws just bubble up resulting in something we will never be able to call "perfect". You are certainly right Munawwar. :)
Page 1 of 1

October 2020

25 26 2728293031

Recent Entries

Recent Comments

Search My Blog

2 user(s) viewing

2 Guests
0 member(s)
0 anonymous member(s)