Console IO in software: a boon or curse?

Have you ever observed that how much does console IO cost to software products?

All software developers from fresher to experience are very much familiar with console IO. In-fact we start learning new software languages with hello world example using console io for example in C printf(), in C++ printf() or cout<< , in Java System.out.println() and in C# console.write() etc.

It is very difficult to learn any languages without this as if we don’t see any output, we cannot know if a program or an application is functioning properly. Every learners, each and every programmers almost use it every day during software development and software maintenance during debugging or writing software concepts, algorithms etc. In some of a complex project we track the issues by putting console IO.

In fact, in many ways console IO is very helpful and it has been really a boon for software developers.

But, do we really focus, how much does it cost to projects and how much to software developers?

In software industries, I have seen many experience developers ignoring console IO cost. And even though they are familiar, they ignore it unknowingly because of strict deadline for project module completion and jump to the next modules. At the end, it still resides in the project/products that affects performance drastically and create pain for developers during development or maintenance as it is very time consuming. e.g. in the complex project you might be fixing issues and waiting to see the result for long, and performing this operation again and again. It should be very annoying, isn’t it?

First, let us see the impact of the console IO with very simple example. Having array for 100000 elements and incrementing it by let’s say 5 and perform other operations.

 

To test the functionalities we put cout operations that’s for good. But,usually we forget to remove it.

In the above example, if you comment the cout operation it will be completed in seconds but if you keep it uncommented, it will take for many minutes. Think about the situation where we’ve got large array and huge loops at multiple places in the complex project.

So, definitely, console IO is a curse if don’t care for it.

Writing here one of the real time scenarios I have seen causing terrible issues, wasting tons of time, efforts and efficiency.

One of my friends had been resolving thread hang issue for a month in a complex project. Issue was, application was getting hang over time within an hour. He was debugging application, varying logical error and other options etc.  Here is the scenario:

In producer-consumer design pattern implemented in the project. There was one producer thread that was filling data in a shared dynamic queue and consumer was reading the data from the queue. There was a constraint that produce should continuously fill data at sampling rate 4 data/ second. Means, 4 nodes of queue is getting added in 1 second. Consumer was consuming data and processing it if there is element in the queue.

By understanding his problem, when I reviewed the code, I first focus on console IO if any, as he had already spent tons of time with logical errors. So, chances of logical errors was very less.

I found that there was a huge console IO in the loop and this was the culprit. It was spending lots of time in console IO operation and slowing down the processing. So, consumer thread was consuming data from queue at very slow rate and producer was producing it at very fast rate. As a result, entire memory was getting filled with data nodes and finally an application hang.

Now, you can think yourself, the cost of console IO from time, efforts and efficiency perspective.

Conclusion:

  1. Console IO is very helpful in verifying functionalities and finding logical errors in complex projects.
  2. Console IO is very costly, as it is very time consuming operation. So, we need to be careful about it.
  3. It drastically affects the performance of the applications and consume tones of time of software developers.
  4. In the projects, if we have huge number of console operation then don’t remove it, as it will take huge amount of time in removing and writing over and over as we may get a chance to work on those area again. So, put the guard on it. E.g in debug version   #ifdef _DEBUG ……#endif etc     and deliver product in release version.