Code Factory — Introduction

Shafi Sahal
DataDrivenInvestor
Published in
5 min readJan 16, 2021

--

This is an attempt to explain the basic concepts of programming with the analogy of a factory. Out of the many analogies I searched it was found to be the most convenient. Studying coding with the help of analogy will make it more easy to understand, less confusing, less boring and also helps to approach coding in the same way we interact with the world. For those who knows how to code already, it would be interesting to see it from another perspective.

This article explains what is a software, computer program, hardware and microcode using the factory analogy. Articles coming later will explain the real coding concepts using the factory analogy.

Factory = Software

A factory is an industrial site that produces goods from raw materials with the use of machines and labour. Simply we can say, a factory is a system that produces an output from processing the given input. The goods are the output and the raw materials are the input.

Similarly, the software is a system that produces output from processing the given input. Inputs are the data given to the software and output is the data given by the software whereas in a factory raw materials are the materials given to the factory and goods are the materials given by the factory.

Plan = Computer program

A factory will have a detailed plan on how to construct it, what machinery to be bought or built, what each employee should do, how the whole system will coordinate, and so on.

Similarly, a computer program is a detailed plan on how to construct the software, what libraries should be imported, what functions to be built, what each function should do and how the whole system coordinates, and so on.

Engineer = Compiler

After planning, an engineer transforms the abstract plan into real world materials. He decides what will be the amount of materials used, which materials to be used and so on. To put it simply, the engineer converts the abstract plan on a paper to real world bricks, stones, steel etc.

This is what a compiler does. The compiler transforms the abstract or high level programming language to the machine language or the digital world binaries: 0’s and 1’s. The compiler decides how to arrange the binaries to build the software. Binaries are the building blocks of the digital world. Similarly, the thing which converts assembly language to machine language is known as assembler. Compiler and assembler do the same thing except compiler translates high level language to machine language and assembler translate assembly language to machine language

In the same way a plan is not the actual factory, and actual factory is the one that is built from real world things according to the plan, a computer program is not the actual software, and actual software is the one that is built from digital world binaries according to the computer program.

Universe = Hardware

A factory is built in a universe, more specifically on planet earth. Without a universe a factory cannot be built. Universe provide the fundamental things: space, energy, matter and time to built factories.

Similarly, a software is built in a hardware. Without hardware there is no software. Hardware provides the fundamental things: Memory, power(electricity) and logic circuits.

Laws of nature = Microcode

The laws of nature or laws of physics, are the laws or the means by which the universe work. Without physical laws: space, energy and time does not interact and without the interaction there is nothing going on in the universe. The whole universe would be frozen. When you push a box, your energy gets transferred to the weight and thus it moves. But the how much energy should be transferred is dependent on your efforts and lots of other parameters like material of the box, friction, your strength etc. It’s the laws of nature that decides how will the energy transfer and by how much. It’s this interaction that keeps it working. Construction of a factory is only possible if space, time and energy interacts with each other.

Microcode is what makes the interaction of hardware possible. When a processor is designed, a microcode is also made for the processor. Microcode helps the processor to convert the machine language to the real processing through the circuits in the processor.

Machine code or binary is analogous to the materials or the box and the person in this case. Machine code itself don’t do anything. It is the microcode like the laws of nature decides how the process will be run.

The processor receives the binary data or machine code from the compilers or assemblers and does the actual processing of these data through the circuits in the processor. So, how a processor works depends on the microcode and the whole software whether it is an application or an operating system, without microcode none of them will exist.

It is with the help of microcode hardware interacts with each other and it is this interaction that makes it possible to build and run the software.

In computers for making the usage of applications easier, an operating system is used to communicate with the microcode. Operating system through it’s core program called kernel communicates with microcode and controls the hardware. This will make the development of applications that run on the operating system easier as they do not need to have codes to control the hardware. Controlling hardware will be done by the operating system and microcode. So the one who develops the application only need to think about the working of the application

Summary

Basically this is how a software is built and run:

  • A computer program is written
  • A compiler converts the program to the machine language.
  • The operating system communicates with the hardware and assists the compiler in delivering this program in machine language to the microcode.
  • The microcode converts the machine language to the real processes in the circuits of the processors.
  • Through the processes in the circuits, the software is finally run.
  • A software is built in the digital world!!!

--

--

Developer, adventure lover and a truth seeker. Like to write about topics from a unique perspective. Twitter: https://twitter.com/_shafisahal.