Fundamentals of Computer
Programming Languages
Introduction
What is Computer Programming?
Computer programming is the process of creating instructions for a computer
to execute.
These instructions are called code, and they are written in a programming
language.
Programming languages are sets of rules that define how code is written and
interpreted by computers.
There are many different programming languages, each with its own strengths
and weaknesses. Some popular programming languages include Python, Java,
C, C++, and JavaScript.
Classification of Programming Languages
Based on level of abstraction, programming languages are classified into follow-
ing categories:
• Machine Code
• Assembly Language
• High-level Language
• Very High-level Language
Machine Code
• Machine code is a low-level programming language that is directly under-
stood by the computer’s hardware. It is a series of binary digits (0s and
1s) that represent instructions for the computer to execute.
1
• Machine code is the lowest level of abstraction in programming languages.
It is the only language that the computer can directly understand, so it is
the fastest type of programming language.
• Machine code is very difficult to write and maintain, so it is rarely used by
programmers. However, it is sometimes used for applications that require
high performance, such as operating systems and embedded systems.
• Machine code can be generated by a compiler or an assembler. A compiler
translates a high-level language into machine code, while an assembler
translates assembly language into machine code.
Example of Machine Code
01001000 01000001 01000001
This code tells the computer to load the value 1 into the register 0.
Assembly Language
• Assembly language is a low-level programming language that is used to
control the hardware of a computer. It is a mnemonic representation of
machine code, and it is used to write programs that are very efficient and
close to the hardware.
• Assembly language is more difficult to learn than high-level languages,
but it is often necessary for writing code that requires high performance
or that needs to interact with the hardware directly.
• Assembly language is also used to write macros, which are reusable blocks
of code that can be used to simplify the writing of programs.
Example of Assembly Code
mov ax, 10
mov bx, 20
add ax, bx
This code tells the computer to add the values 10 and 20 and to store the result
in the register AX.
Benefits of using Assembly Language
• Performance: Assembly language programs can be much faster than
programs written in high-level languages. This is because assembly lan-
guage programs have more control over the hardware, and they can be
optimized for specific platforms.
2
• Control: Assembly language programs have more control over the hard-
ware than programs written in high-level languages. This can be useful
for tasks that require direct access to the hardware, such as device drivers
and operating systems.
• Portability: Assembly language programs are often more portable than
programs written in high-level languages. This is because assembly lan-
guage programs are not as dependent on the specific platform that they
are running on.
Challanges of using Assembly Language
• Complexity: Assembly language is a very complex language. This can
make it difficult to learn and to write programs in assembly language.
• Debugging: Assembly language programs can be difficult to debug.
This is because assembly language programs are often very close to the
hardware, and it can be difficult to track down errors in the code.
• Maintenance: Assembly language programs can be difficult to maintain.
This is because assembly language programs are often very specific to the
platform that they are running on.
High-level Languages
• High-level programming languages are designed to be easy for humans to
read and write. They are translated into machine code by a compiler or
interpreter.
• High-level languages are often used for general-purpose programming, but
they can also be used for specific tasks, such as web development, game
development, and artificial intelligence.
• Some popular high-level languages include:
– Python: A general-purpose language that is easy to learn and use.
– Java: A general-purpose language that is widely used for enterprise
applications.
– C++: A powerful language that is often used for systems program-
ming.
– JavaScript: A language that is used for web development.
– PHP: A language that is used for web development.
Benefits of using High-level Languages
• Readability and writability: High-level languages use English-like syn-
tax, which makes them easier to read and write than low-level languages.
This can lead to faster software development, as well as easier maintenance
and debugging.
3
• Portability: High-level languages are typically platform-independent,
meaning that they can run on any computer with a compatible compiler.
This makes it easier to distribute software and to run it on different types
of hardware.
• Abstraction: High-level languages provide abstraction from the under-
lying hardware, which makes it easier to write code that is independent
of the specific machine it is running on. This can lead to more portable
and reusable code.
• Libraries: High-level languages typically have extensive libraries of pre-
written functions and subroutines. This can save programmers a signifi-
cant amount of time and effort, and it can also lead to more reliable and
efficient code.
Challanges of using High-level Languages
• Performance: High-level languages are typically slower than low-level
languages, because they have to be translated into machine code before
they can be executed. This can be a challenge for applications that require
high performance.
• Memory usage: High-level languages typically use more memory than
low-level languages, because they need to store more information about the
abstract data structures they use. This can be a challenge for applications
that are memory-constrained.
• Control: High-level languages give programmers less control over the
underlying hardware than low-level languages. This can make it more
difficult to optimize code for specific hardware platforms.
4
Examples of High Level Codes
C Code
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
C++ Code
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
Python Code
print("Hello, world!")
Java Code
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, world!");
}
}