Let’s start from scratch!
We all heard about this statement
`C is a programming language used to program a computer.`
Lets get into it
So `what dose program a computer really mean???`
program a computer mean
To make computer work as I like or something that I tell computer to do for me.
How would I tell computer (ie machine) to do what I say?
Computer don’t understand the human languages like english or any other human language
So we need a language that would be understand by the computer.
The language understood by computer is Binary (1,0)
computer only understand 1 (on) and 0 (off)
Note:
The on and off dosen’t mean switch off computer switch on computer.The "on" and "off" states are directly related to the voltage signals in a transistor, which act as switches to control binary logic — also known as digital logic.
[ why computer only understand 1 and 0 is a deeper concept .currently just remember/understand computer can only understand 0 and 1 ]
If computer only understand binary (1 0) .If i want to add two number I need to tell computer
similarly like this
10001010 (first number)
01010001 (first number)
01001101 (operator)
(that binary instruction is not exactly correct. it is just for sake of understanding)
So when we use these kind of instruction it is very hard to read ,understand and when a bug/error occurs we don’t understand or its hard to understand were it is.
To make programming easier, we needed a language that was more human-readable, similar to English. To address this, scientists developed a language called Assembly language.
Assambly Language
Assembly language is a low-level programming language that is closely related to machine code.
There are many types of assembly languages, each designed for a specific type of processor. Some of the most popular ones include x86 Assembly, used in Intel and AMD desktop and laptop processors, and x86-64 Assembly (also called x64), which is the 64-bit version used in most modern computers. ARM Assembly is widely used in smartphones, tablets, and embedded devices because of its power efficiency. MIPS Assembly is popular in education and networking devices like routers, while RISC-V Assembly is a newer, open-source option growing rapidly in research and modern embedded systems. Other important assembly languages include PowerPC Assembly, used in older Macs and automotive systems; SPARC Assembly, found in enterprise servers; Motorola 68k Assembly, common in early Macintosh computers and arcade machines; 6502 Assembly, famous for powering devices like the Commodore 64 and Nintendo Entertainment System (NES); and Z80 Assembly, used in early personal computers like the ZX Spectrum. Each of these assembly languages is tailored to match the design of its specific processor, but all serve the same purpose — to give humans a more understandable way to instruct computers without writing raw binary code.
ARM based assembly language (code snippet example)
MOV R0, #5 ; Move the value 5 into register R0
MOV R1, #3 ; Move the value 3 into register R1
ADD R2, R0, R1 ; Add R0 and R1, store the result in R2
simple x86 Assembly snippet (code snippet example)
MOV AX, 5 ; Move the value 5 into register AX
MOV BX, 3 ; Move the value 3 into register BX
ADD AX, BX ; Add BX to AX
After running these instructions, the register AX will contain the value
(You don’t need to understand the specifics right now, but just know that ARM and x86 are different CPU architectures.)
Assembly language, while more readable than raw binary, can still be quite difficult to understand. Additionally, it is highly dependent on the CPU architecture, meaning that the assembly language for one type of processor (like ARM) will be completely different from that of another (like x86). This makes it challenging to work with and less portable across different systems.
The important thing to understand is that these differences contribute to the complexity of assembly language, making it harder to read and understand. Additionally, each architecture has its own unique set of instructions and behaviors, which can make working with assembly more challenging.
To reduce complexity and make programming easier, scientists Dennis Ritchie and Brian Kernighan developed the C language. It was designed to be closer to human language, making it more intuitive and accessible for programmers.
Code snippet of C language
You might wonder, "If computers only understand 1s and 0s, how do they understand C language?" The core mechanism behind this is the compiler.
A compiler is a program that translates C code into machine code — the binary instructions (1s and 0s) that the computer can understand and execute. When you write code in C, the compiler converts it into low-level machine language that the processor can execute. This process makes C code more cross-platform, as the same C program can be compiled for different types of hardware, enabling it to run on various systems without major changes.
Some examples of popular C compilers include GCC, Borland Turbo C, and Clang, among others.
Summary in short
In this blog, I’ll explain the need for C language to simplify programming, why assembly language can be challenging, and the importance of programming languages in general. This is an introductory guide designed for absolute beginners to help you grasp the basics and understand why programming languages are essential.
Program a computer—Machine Code(binary)--assembly--C---Compiler
Some reference you can use
"Hope you enjoyed! Thank you for reading, and happy learning. If you have any doubts, feel free to email me at authour@magnetonn.in