DEV Community

Cover image for Essential prerequisites for programming
Chiranjeevi Tirunagari
Chiranjeevi Tirunagari

Posted on • Edited on

Essential prerequisites for programming

Context

When starting to code, most beginners do the same mistake of diving right into it without having a context. Whenever we are starting something, we should start from a context just like this article that gives us a high-level overview, which helps us in deciding if we want to continue on that path or if it is something that doesn't excite us.

By the way, I am Chiranjeevi Tirunagari, working as a Product Engineer at Oslash. When I started to code, I didn't have much context on anything related to coding for many reasons. I did it anyway since it was my major in college. But, having the right context could have made me a better coder/programmer/engineer than I was, a lot faster.

The motive of this article is to provide the right context before someone starts their coding journey for which I am going touch on 4 topics which are:

  1. What does exactly programming mean in the context of computers?
  2. Code vs Program vs Software.
  3. The basic architecture of computers.
  4. How does program execution work?

1. What does exactly programming mean in the context of computers?

Telling a computer to do a specific task is called programming. Yes, that's exactly what it is. It can be anything from asking a computer to "tell an answer to a complex arithmetic operation" or "send some data or a set of files to another computer over the internet, also called web development" or "analyze past data and predict the future, also called machine learning". The task can be anything that is done by the computer, but one thing is common, being a programmer it is our task to tell the computer how to do that task, and that is called programming.

Since the computer is a machine that runs on electricity, all that is understood by a computer is a 0 or a 1 (binary language) under the hood, we need to program in such a way that the computer understands what we are programming. So, do we need to program in binary? Fortunately no. There are two things called compiler/interpreter (converts programming language code into machine level code) and operating system (converts machine level code into binary) which we will talk about later which do all the hard work to make the computer understand our program written in a language that we can understand by translating it into binary.

2. Code vs Program vs Software.

These are the words that people often use interchangeably even though they are not the same. The difference between these 3 is not something straightforward. It depends on the person's perspective on these words. Here, I will try to convey my perspective on all three of these.

  • Converting a word from one language to another is what actually coding is. A code in terms of computers is something we write in a language we understand and can be converted into something a computer can also understand. A code can exist without a purpose. This can be understood by the following example. Telling a computer to ask the user to tell their name is a code. Just taking the name from the user is not at all useful from any angle. But still, it is a code because we can tell the computer to do that even though it is not useful.
  • A program is something that is written to serve a purpose. All programs consist of code but do meaningful things. Considering the previous example again. If addition to taking the name from the user, if we are greeting the user with their name, then it is something meaningful. Here the purpose is to greet the user and not just do something that is useless. All programs are coded, but not all that are coded are programs.
  • Finally, the software is a collection of programs that aims to solve a problem. Let us consider an example here too. The program to greet a user is meaningful but not solving any problem. Nobody uses something just to greet them. If we have a set of programs that are helping the users pay their bills, of which the greeting program is also a part, then this set of programs can be called software as it is solving a problem. An operating system that we saw before is also software that solves the problem of dealing with the low-level implementation of other software executions to make computers understand them.

3. The basic architecture of computers.

The idea here is to show how the most important parts of a computer are connected together. The parts here don't mean devices like keyboards, mice, etc. A computer can still work without them and do the task it is supposed to do (alexa, smart homes, etc). Here the intention is to show the things which are absolutely necessary for every computer to function.
The two most important parts of a computer are CPU and memory.

  • A CPU is a chip that actually performs the execution of code/program/software on it. It is usually referred to as the brain of the computer.
  • Though the CPU is what performs the execution, there should be programs existing somewhere to make it available to the CPU to run and memory is what does that for the CPU. The memory stores the programs and passes them to the CPU whenever required to be run.

CPU and memory

4. How does program execution work?

All that is there above this point just provides context for this section. This is the most important part of this article at least from my perspective.
As seen in the previous section, memory is one of the most important parts of a computer. There are 2 types of memory. They are primary memory and secondary memory. Primary memory devices are designed in such a way that the exchange of data between primary memory devices and CPU is much faster when compared to secondary memory devices.
But the primary memory is volatile in nature which means that once the power supply is off to the computer, the data in primary memory is gone and becomes empty whereas the data in secondary memory is non-volatile and stays even if the power supply is off.

Memory types

This is the reason why the programs and software are stored in the secondary memory initially. When these programs are executed by the CPU, the code for the program is loaded into the primary memory and executed line by line.

Conclusion

What I have mentioned here is just the outline of what actually happens. There are lot more low-level things like PC, MAR, and MDR involved in this process and maybe they are topics for some other day. But, this is the bare minimum that we need before starting to learn to program. This feels very basic and intuitive if you already know it. But, most people don't know these basics and jump right into coding and struggle to understand.

That's it for this one. If you find this helpful, do share it with others. Please like and comment if you have any suggestions.

Make sure you follow me on Youtube and other social media platforms for more such content.
Youtube
LinkedIn
Twitter

Top comments (0)