Bad Code is Finally Bad Code
Being a programmer, bad code is a bit of a pet peeve of mine. I will be the first to admit I am not the best most efficient programmer, but there are many many many programmers that are a whole lot worse than I am. I have worked on a lot of really bad code. I wouldn’t even say the code was written by programmers. A lot of code out in the world that I have worked on was written by people who don’t really know how to write software. I just read a post here explaining how, in the author’s opinion, bad code matters now.
I found the post interesting because it only highlights one of the biggest problems with bad code. It is only a problem when it becomes a problem for you. The author states that “Once upon a time, lousy coding didn’t matter.” Maybe it didn’t matter to the author, but lousy coding has ALWAYS mattered.
Poorly written code has always resulted in higher cost. More CPU resources, more memory, more storage space and higher maintenance costs. If it worked on the hardware being used at that time though, and seemed to work ok to the end user, it was thought that the internal code didn’t matter. I work on code where 1 bit of data is stored in 16bit words. I work on code where I have deleted 60% of a program without affecting its operation at all, and the code is still horrible because it was so poorly written to begin with. At the time it was written, it was considered unimportant because it ran with the hardware and the software that was available at the time. It is very hard to work on though. It can be nearly impossible to make changes to, and whenever you need to modify it or make additions to it, you are always battling memory limitations and storage problems.
As a programmer though, it is difficult to demonstrate this to a potential customer or your employer. You can look in code that makes you cringe, but on the outside, to them, it looks like it is working, so it doesn’t matter. The problems won’t show up until later, like buying a cheap car or a poorly constructed house. Years down the road, the bad code will end up being orders of magnitude more expensive than the good code. It can cause hardware to fail prematurely. It can cause unexplainable lock ups or crashes that no one can ever resolve or explain. Business is all about the here and now though. Business is all about how much money can be made between today and the end of the next fiscal quarter. This does not promote the hiring of the most skilled programmers to write efficient well written code. It promotes the hiring of the cheapest programmers that can get something that looks like it is working out the door before the end of the quarter.
I remember the first time I saw the difference that efficient code could make. It was my first job out of college. I was working at a company doing some embedded systems development on an embedded controller in the automotive industry. I had written some code, which I thought at the time was quite good. It worked well and did what was needed, but it was sloppy and as a result used more of the resources of the embedded controller than was necessary. I didn’t know this though. A more experienced programmer, essentially my mentor at the time, rewrote my code. When I first heard this, I was a bit miffed, until I saw it. He had taken what took me about 20 lines of code to accomplish and had compressed it down to 2. I had to study that code for quite awhile to figure out how he had accomplished what seemed to me like an almost miraculous feat. It was because of his experience that we were eventually able to write control code that would fit in this embedded controller with almost no resources. Otherwise we would have needed to use a more powerful controller with more memory that used more power and that would have cost more money for every single unit ever sold. This was at least 15 years ago.
Since that time, software has become HUGE. Every generation of each new operating system has required more resources to even be able to run. From Bill Gates infamous quote in 1981 that no one would ever need more than 640k of RAM, to today when you need 1GB to even think about running his company’s latest operating system with any kind of acceptable performance. This has consistently resulted in the need for more memory, faster processors that use more power, and more storage. This costs more money. It has always been this way and it has ALWAYS mattered.