Skip to main content

Introduction to Computer Science.

 Before directly jumping deeply in c++, let's first start by creating the roots of computer science.

In this post we will answer the following question.
  1. What is Computer and How it works?
  2. What is Program and Operating system?
  3. Low Level vs High Level Language?
  4. Compiler v/s Interpreter?

By Knowing All these basic concepts You will be able to understand the upcoming more complex concepts easily.

Let's start answering the above questions.

What is Computer and How it works?


What is computer?

If I answer briefly, what is computer? then it is just a calculator used for doing simple calculations. If I have to answer where is computer used?, then I could probably say everywhere. We are surrounded by computer, for example mobile, smartwatches, and personal computer (obviously). 
The below image is the first mechanical computer that we used for calculation.
                                      
Abacus


How computer works?

The computer's internal functionality is a whole separate branch. We will discuss only the required knowledge.
The computer has two main parts the CPU(central processing unit) and main memory.
CPU is the device where all the calculations are held, It is made with various electronic components.
CPU block diagram
Now you are wandering what are all these names written in the diagram.
Let me discuss them one by one.
  1. Register is just an storage device(but then what is main memory? It's a storage too). Registers are small and quick memory devices that are used to quickly access the next operation to perform. Here you must be thinking what is meant by next operation. Let me explain, as we know computer operates on data with sequences of operations, and registers simply stores the next operation to perform present in that sequences, there are various types of registers, click here for more info.
  2. Arithmetic Logic Unit(ALU) is the part of the CPU where all the calculation on the data happens. You can clearly see the registers pointing to a shared place between ALU and CU(control unit). It means, registers are accessible by both ALU and CU and it can easily tell them what to perform next.
  3. The control unit (CU) is a component of CPU that directs the operation of the processor. It means that it handles computer's memory, ALU and input output devices to tell them how to respond to the given instruction.
  4. Bus, you can relate it to the real one too. What Bus do is to transport passengers. Here the passengers is simply not the human or dogs or anything else.. but the data.
  5. Main Memory is a temporary storage device, now what the word "temporary" doing here. Let me explain this through an example, if you have windows installed in your system then open task manager using the shortcut ctrl+shift+esc and note down your memory(RAM) usage, now, If you have any heavy game or any application then go and start it(don't forget to come back) now again open task manager and you will see that memory usage is increased, and if you close that program it will again released. Now, this is what temporary means, when you start anything in your computer it do not start directly from your hard disk but firstly it will be transferred to the main memory and after that it will open and after closing the program it is also be deleted from the memory too.
Now let's come back to main question how computer works. 
When you given some input to the computer it will first stored to the input buffer, so that CPU and main memory can access it.
After Accessing input from the user the operations are performed on the data by CPU and again the data is transferred to the output buffer, so that Some output device generally we have Monitor, but it may be printer and anything else, can access that data.
(Extra thing to remember - Computers uses machine language i.e. 0s and 1s but not the English or french or any other language. I will discuss it in more details in future.)


What is Program and Operating System?


What is Program?

A program can be considered as a set of ordered operations that computer perform.

What is Operating System?

An Operating System is also a program but it is the most essential program that a computer needs to run. When you turn on the switch of your computer(assuming that you have electricity supply), the first thing that computer do is, it loads a program, wait ๐Ÿค” which one? Our most precious The Operating System. The process that how loading is done is similar as I have discussed in the main memory section.


Low Level language v/s High Level Language

  • High Level Language is easy to read but Low Level Language is not.
  • High Level Language is easy to debug but Low Level Language is not.
  • High Level Languages are much more used as compared to Low Level Language(Who wants to do difficult things๐Ÿ˜ฉ.)
  • High Level Language needs compiler or interpreter for translation while Low Level Language needs assembler.

Compiler v/s Interpreter

The functions of compiler and interpreter are same, to run the given code/program/kodikas(in greek).. 
But(that's a big but), the approach of compiler and interpreter are different.
Differences are written below.
  • The compiler converts the whole code to a separate stand alone machine code file while interpreter runs the given code line by line and do not create a separate machine coded file.
  • There are terms like linking, object code etc, If you are familiar with them it's Good ๐Ÿ‘, if not, then skip it for now, I will be discussing them in very detailed form in future๐Ÿ˜‰.
(Extra thing to remember - C++ is a compiled language, don't worry we will discuss it too.)

Stay tuned for the upcoming content. For any query leave a comment below.

Click the Subscribe button at the top, to follow my every post regarding c++.

References -
  • Wikipedia.
  • GeeksForGeeks.
  • Lippman, Stanley B. c++ primer 3rd edition(april 2, 1998).

Comments

Post a Comment

Popular posts from this blog

C-style strings vs String Class.

Here, we are going to learn about, what are C-Style Strings and what is String class . So, let's start by giving you the introduction. C-Style String is nothing but, an array of characters, and from the term array we can surely assume that these are static in size i.e. the size of these C-Style strings cannot be increased or decreased. String Class is a Built-in class that provide us much more functionality than C-Style String. C-STYLE STRINGS Before learning the String class, which is full-fledged feature of C++, we should rather start by taking a look at some important things about C-Style String. C-Style Strings are actually array of characters that are terminated by a null character "\0". If you are confused with, why null character? The reason is that, It helps us to define, upto which index we have some useful data present in our character array, and after null character there may or may not be some garbage values of characters. Let's first start by showing a

Algorithms, Pseduocodes and FlowCharts.

Some Basic Knowledge. C++ is a general purpose programming language, created by Bjarne Stroustrup and was firstly released in  1985. It is an extension to C language, Reason for that is if you are familiar with C language than you must be familiar with the fact that there are no classes, templates etc. present in C language. Due to which when classes are added to C language it is named as "C with Classes", but C++ is considered as default name now.  Extra thing to remember - In "C++" the symbol "++" after C is post increment symbol and therefore, "C++" means that In C additional features are added. Now, let's define, what are algorithms? Algorithms are nothing but set of rules that must be followed to accomplish some task. (Now, What that mean?๐Ÿ˜•) let's take an example of swapping two numbers, i.e. if a = 10 and b = 20 after swapping a = 20 and b = 10. How will you write the procedure for this?  (There are many such algorithms). Accordin