class="w-100 Demystifying Programming: How, When, and What You Need to Know

How does a computer work?

Let's start with very basic things:Suppose we have four different electrical items, as shown in the figure. If we want to start one item, we have to turn ON the switch. It's very common sense. But suppose I have 1000 electrical devices at one place,that means I have to make 1000 switches also.

If I have to TURN on or off a particular device at a certain speed,the problem is:
Time consuming.
I cannot remember the switch position of every device.
Wires Cost and maintenance are cumbersome.
Here comes a very important invention of the 20th century, i.e., the transistor.It is a three terminal device. The three terminals are the emitter, base, and Collector. It acts like a switch. The difference is that here the switch is controlled manually, but the transistor is controlled by voltage directly. The transistor conducts current in the collector-emitter path only when a voltage is applied to the base. When there is no base voltage, the outlet turns off.

What are logic gates?

Logic gates are combinations of these transistors joined in a pattern, like the output of one transistor attached to the emitter of another transistor, etc. In such a way, we can achieve a particular output on a given current at particular switches, as explained in the given animation. Here, the two transistors are attached to one another, and each transistor is attached to a switch. A fixed voltage is given, and the output is dependent on which input (A or B) is ON. Here, 0 means No current, and 1 means there is current. This 0 and 1 combination is called "Binary language".
Programming Basics Explained "Programming for Beginners">
We can make different types of gates with different combinations of transistors.

Decoders

Like Logic gates are combinations of transistors, decoders are combinations of logic gates. Decoders are used in our CPU to carry out operations. We will see how, but first let's see the workings of decoders in the below animation.

So as we can see, we were able to control 4 devices with only 2 switches.
0 0----->First device
0 1----->Second Device
1 0----->Third Device
1 1----->Fourth Device


With 2 inputs, we can achieve 4 output modes,
3->8
4->16
5->32
6->64
7->128
8->256
9->512
10->1024 etc.
So finally, we are successful in controlling more than 1000 devices with only 10 switches.

Now, after the invention of these decoders, computer scientists start making computational devices like calculators by combining millions of decoders, gates, etc.What is inside our CPU It has millions of small devices, such as a fan and USB port, and also assumes the small pixel display of the monitor as a single device.Here comes the magic part: we know the CPU is controlled by the processor (the brain of the CPU). A processor is nothing but the blend of decoders that are responsible for turning ON and off a particular device according to the binary input received at such a fast speed that it results in controlling the monitor display,mouse input,speaker output, etc. properly.
Now the question arises: How the hell can we remember the 0/1 combination for a particular output in millions of them, or who gives that binary input?

Compiler

A compiler is a device (in reality, it is software,but for instance, assume it is a hardware piece) to which we give input in "English" under some set of rules, and that input is converted into assembly language, which is again converted by the assembler to a 0 or 1 combination. Here, the set of rules is known as "programming language". Therefore, every piece of software on a PC is written in a programming language. A 0 or 1 combination means blocks of pulses of power or no power (0s and 1s) start flowing into the CPU and are decoded by the processor.

History

The first commercially available programming language was C. It is the fastest-known language because it was directly made for hardware. But the structure of rules in C is very complex, and memory management is also difficult.

Therefore, C++ was made to overcome this issue. It is an object oriented programming language. Object means data. In C++, more emphasis is placed on data instead of steps, unlike in C, which is a step-oriented language.

But C/C++ languages are hardware dependent. Ex: When you install an app from the Play Store, you are actually downloading the 0-1, which is generated by a compiler. The c/c++ compiler generates 0–1 specifically for hardware, which means if it generates on Windows, those combinations will not work on Mac, and vice versa. So Java came into existence, in which instead of the compiler converting 0 to 1, it converted the program to byte code that is independent of hardware,and can be run on any device if that device has JVT on it. This makes Java the most popular language.

When the Internet was created, there was a need for a language that could control the flow of data from a company website to a client. So PHP was made out.

Like this, many languages were created. There was a person known as GON VAN ROSSUM who saw an issue in these languages. In these languages, to store a single piece of data,we have to tell the compiler the amount of memory required for the data, the type of data, and sometimes the location of the data on the hard disk, which makes the simple storage task as complex as possible. So he decided to make a language for data handling, which we know today as Python.That’s why Python is used in Data Science due to its easy data handling.

How to code?

Coding is simple, like learning a foreign language. What we do:
First learn alphabets ---> Words ---->Sentence---->Meaning
Same in Coding
Learn alphabets (symbols) -->Keywords(prewritten words having special meaning)-->Sentence-->Compiling
Let's take the example of Python.As we learned earlier, to program, we need a compiler for that language. Let's download it from a website named "Anaconda". The Anaconda package contains a compiler, libraries (pre-written programs), and different IDEs (an editor where we write code). Click Download and install the app on your PC.

Programming Basics Explained

After installing, Open Jupyter-Notebook from the Search Menu.
Create a new file, and you will see cells of Jupyter.


Let's write the first program. As we discussed earlier, we need to learn symbols and keywords and know the rules to make sentences.One thing is more, i.e., built-in functions. Inbuilt functions are simply pre-written code with a name given to them.So there is a function known as "print", whose task is to display something on screen.

We can see that first we write "print" after it in round brackets (rules to execute a function). In between brackets, we write the word or sentence we want to display. The Output of the whole program is just below the program.We will discuss Python further in another blog.
Keep Coding!

Free Career Counselling

We are happy to help you 24/7