Eli5 what a STDOUT is in computing and what’s an example of it?

604 views

It’s so hard to understand what it is with definitions from Wikipedia and other random websites that come up when I Google it

In: Technology

4 Answers

Anonymous 0 Comments

Software programmer here, others have given you the simple answer but I’ll give you the in-depth one:

The most basic data structure is an array. An array is a fixed length chunk of memory that you can store more than one item in.

Arrays have several problems though, in particular that they are fixed length. We can improve an array by changing it into what C++ calls a vector (other languages call it a list or an array list). This data structure wraps the array with some logic. When the array gets full, the logic automatically creates a new larger array and moves everything to it.

We will focus on a specific usage of an array called a queue. A queue has elements created at the end and deleted at the beginning. However, a basic implementation of a vector can’t easily delete elements at the beginning and so instead would waste time and effort. To fix this, we make the vector “circular”. This changes the “beginning” from a fixed position at the start to moveable. Think of this like an image of an ouroboros, the snake eating its own tail. Essentially, it allows us to re-use space at the start of the array that was taken up by deleted elements without needing to move existing elements.

The next and final improvement is a bit different. Moving data from one place to another is a very common operation. While this can be done using a circular vector, we really don’t want to be bothered by all of these complex details of how exactly it is done. So we separate the usage of it (interface) from the details of how it works (implementation). We call the resulting data structure for moving data from one place to another a stream. We don’t care how a stream is built under the hood. It might use a circular vector, or it might use something more complicated. What we do care about is a stream’s interface, which has two main pieces of functionality: writing data to the stream from a source, and reading data from the stream to a destination.

To finally answer your question, STDOUT is a special stream called “Standard Out”. What makes it special is three things: it is automatically created when a process is launched, special functions like printf write to it by default, and your screen reads from it by default.

You are viewing 1 out of 4 answers, click here to view all answers.