What is a File?

Mayowa Obisesan
3 min readDec 17, 2023

--

File icons created by Dimitry Miroliubov — Flaticon

In December of 2023, I was learning about translation units in C++ and a question crossed my mind. What is a File? I understand that everything in the world of computers revolves around memory. But what is a file? Because thinking about it, a file can contain data that will also be stored in memory. A file can hold thousands of words, all stored in memory. That is understandable. But in the case of a computer program that also contains things like variables and structs and arrays and objects and other complex data types that needs an address to be referenced, how do they work.

I quickly realized that a computer program is just a normal file that is stored in memory, the concepts of variables and structs and the complex data types does not exist to the file when it is stored as a .cpp file or .py file or .rs or .js or any other extension. The file is just normal text that is stored in physical memory and loaded onto the virtual memory as the need arises. Then another question arises. If my program file is just a text file loaded into memory, why do we have specialized software that can execute some type of files. The answer is in the question.

The reason why there is a need for specialized software that execute a computer program written in a .cpp file is because the text needs to be transformed into an executable (which we refer to as applications or games) and only specialized software can handle that transformation from text to executable binary. The process of transforming the file in memory to the application that we can relate with is what is known as COMPILING and in some languages, LINKING and the software that performs this compiling is known as a COMPILER while the software that handled the linking process is known as a LINKER.

Having this understanding clarifies that a computer program code is just a file with no code meaning until it needs to be processed by the compiler or interpreter that will give meaning to the code you have written. To understand how compiler performs this transformation, I will link to an article about how compiler and linking works at the end of this article.

So, what is a File? A File is a block of text that is stored in persistent storage and that can be read into memory and remain in memory until it is closed by a closed operation. A file can be executed by reading the contents of the file into a memory block which then can be processed, manipulated, deleted or converted into another form and closed once any of those READ, UPDATE and DELETE operations have been performed.

CONCLUSION

This is a basic understanding of what a file is, how files are read into memory, how files executed and how a typical file is converted into an application or a game that you interact with on your phone or laptop or tablet and any other computer gadget. The starting point for all of these is a file.

I tried to explain what a file is in simple terms as much as possible. There are much more that happens about a file that I haven’t covered in this article. These are much more technical details that will need a lot of concepts and an understanding of file systems to understand. If you are interested in the technical details, there are lots of resources, but I’ll recommend you can start with a resource on computer file system or a computer science course on file systems. That’ll be very helpful.

OTHER RESOURCES

Here are some articles I have written that will help understand some of the terms I have used in this article.

Thanks for reading. 🙂

--

--

Mayowa Obisesan
Mayowa Obisesan

Written by Mayowa Obisesan

Entrepreneur | Computer Scientist

No responses yet