0% found this document useful (0 votes)
12 views5 pages

Overview of Programming Languages

This document provides an introduction to computer programming languages, defining them as formal sets of instructions for communicating with computers. It categorizes programming languages into low-level, high-level, scripting, and markup languages, detailing their features, examples, and use cases. Additionally, it includes an introduction to C++, example programs, and exercises for practical application.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Overview of Programming Languages

This document provides an introduction to computer programming languages, defining them as formal sets of instructions for communicating with computers. It categorizes programming languages into low-level, high-level, scripting, and markup languages, detailing their features, examples, and use cases. Additionally, it includes an introduction to C++, example programs, and exercises for practical application.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULE 1:

INTRODUCTION TO COMPUTER PROGRAMMING LANGUAGE


Definition of a Computer Programming Language
A computer programming language is a formal (structure define) set of instructions used to
communicate with a computer and perform specific tasks. It enables developers to write
programs that execute various operations such as calculations, data processing, and automation.
Types of Programming Languages
Programming languages are classified into:
1: Low-Level Languages
1.1 Definition
Low-level languages are programming languages that are closer to machine language and
provide little or no abstraction from a computer's instruction set architecture. They are
hardware-specific and require a deep understanding of the computer’s internals.

1.2 Types of Low-Level Languages

a) Machine Language
• Consists of binary code (0s and 1s).
• Directly executed by the CPU.
• Fastest in execution but very difficult to write and debug.
Example:
binary
10110000 01100001
b) Assembly Language
• Uses mnemonics instead of binary.
• Requires an assembler to convert it to machine code.
• Still hardware-specific.
Example:
Asm
MOV AL, 61h

1.3 Features
• Fast execution.
• Not portable.
• Difficult to write and maintain.
1.4 Use Cases
• Embedded systems
• Device drivers
• Real-time systems

2: High-Level Languages
2.1 Definition
High-level languages are programming languages that are closer to human language and
abstract away most of the hardware details.
2.2 Examples of High-Level Languages
a) C
• Procedural language
• Used for system-level programming
C
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}

b) C++
• Extension of C with Object-Oriented features
• Used in game development, simulations
cpp
#include <iostream>
using namespace std;

int main() {
cout << "Hello, C++";
return 0;
}

c) Python
• High-level, interpreted, dynamically typed
• Great for automation, data science, web apps
python
print("Hello, Python")

d) Java
• Object-Oriented and platform-independent
• Used in Android development and enterprise applications
java
CopyEdit
public class Hello {
public static void main (String[] args) {
[Link]("Hello, Java");
}
}

2.3 Features
• Portable
• Easy to learn and use
• Requires a compiler or interpreter

Scripting Languages
3.1 Definition
Scripting languages are used to automate tasks, usually interpreted rather than compiled, and
often embedded in larger applications.

3.2 Examples
a) JavaScript
• Runs in browsers
• Used for dynamic web content

javascript

alert("Hello, JavaScript!");

b) PHP
• Server-side scripting language
• Used in web development
php

<?php
echo "Hello, PHP!";
?>
c) Python (also used as a scripting language)
• Automates tasks like file manipulation, web scraping

python
print("Automated task running...")

3.3 Features
• Easy to learn
• Fast to develop and deploy
• Often interpreted line-by-line

4: Markup Languages

4.1 Definition
Markup languages are used to define the structure and presentation of data, especially on the
web.

4.2 Examples
a) HTML (HyperText Markup Language)
• Standard markup for creating web pages
html
<!DOCTYPE html>
<html>
<head><title>Page Title</title></head>
<body><h1>Hello, HTML!</h1></body>
</html>

b) XML (eXtensible Markup Language)


• Used for data storage and transport
xml
<student>
<name>John Doe</name>
<age>20</age>
</student>

4.3 Features
• Not programming languages but used to structure data.
• Tags define elements and hierarchy.
• Used in web and data applications.

Summary Table
Category Examples Compiled/Interpreted Usage
Low-Level Machine, Assembly Compiled Embedded, System-level programming
High-Level C, C++, Java, Python Both General-purpose programming
Scripting JavaScript, PHP, Python Interpreted Automation, Web, Server-side scripts
Markup HTML, XML N/A Web layout, Data formatting

Characteristics of a Good Programming Language


• Simplicity and readability
• Portability
• Efficiency
• Robustness
• Maintainability
Introduction to C++
C++ is a general-purpose programming language developed by Bjarne Stroustrup. It is an
extension of C and supports object-oriented programming (OOP), procedural programming, and
generic programming.
1.5 Example Programs
Example 1: Basic C++ Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
Example 2: Adding Two Numbers
#include <iostream>
using namespace std;
int main() {
int a, b, sum;
cout << "Enter two numbers: ";
cin >> a >> b;
sum = a + b;
cout << "Sum: " << sum << endl;
return 0;
}
Exercises on Module One
1. Write a program to print "Welcome to C++ programming!"
2. Write a C++ program to subtract two numbers entered by a user.
3. Modify Example 2 to perform multiplication instead of addition.
4. Write a program to take user input and print the input value.
5. Explain the use of #include <iostream> in C++.
6. Differentiate between machine language and assembly language.
7. Write a simple “Hello World” program in Python, Java, and C++.
8. Explain two major differences between high-level and low-level languages.
9. Create a simple HTML page that displays a welcome message.
10. Write a script in JavaScript that displays an alert message.

Common questions

Powered by AI

Portability is crucial for high-level programming languages because it allows software to be run on multiple hardware platforms without modification, greatly enhancing the software's reach and usability . This feature saves development time and reduces costs associated with writing platform-specific code. Portability is achieved through abstraction and the use of compilers or interpreters that generate machine code for different systems. It affects software development positively by facilitating cross-platform compatibility, encouraging code reuse, and allowing a broader audience to use the software, thus increasing its potential market and user base .

Low-level programming languages, such as machine and assembly languages, are closer to a computer's instruction set architecture and provide little to no abstraction from the hardware . This means they are hardware-specific and require detailed knowledge of the computer's internals. On the other hand, high-level programming languages like C, C++, and Python abstract away most of the hardware details, making them more portable and easier to learn and use . High-level languages are closer to human language and can be compiled or interpreted to run on different machines, whereas low-level languages directly correspond to a computer's binary instruction set, resulting in faster execution but challenging coding and maintenance .

Scripting languages differ from compiled languages primarily in their mode of execution and typical applications. Scripting languages, such as JavaScript and PHP, are usually interpreted and executed line-by-line, which allows for rapid prototyping and ease of deployment, particularly in web development and automation tasks . In contrast, compiled languages like C and C++ translate the entire code into machine code before execution, resulting in faster performance after compilation but requiring more time and resources upfront for the compilation process . Compiled languages are often used in system-level programming and scenarios where performance optimization is crucial. The interpreting nature of scripting languages suits them for tasks like automating processes, handling web page scripting, and managing server-side logic .

Markup languages like HTML and XML have distinct advantages in web and data applications. HTML is the standard for creating web pages and defines the structure and presentation of web content using a system of tags, which allows for consistent and accessible web design . XML is used primarily for data storage and transport, enabling flexible and self-descriptive data representation thanks to its ability to define custom tags and hierarchies . However, a disadvantage of markup languages is their verbosity, which can lead to larger file sizes compared to binary formats. Additionally, while they are excellent for structure and description, they lack the computational power and logic capabilities of programming languages .

Converting high-level language code to machine code involves the use of a compiler or an interpreter. A compiler translates the entire high-level code into machine code before execution, which allows the program to run faster since it is already in a directly executable form . An interpreter, on the other hand, translates high-level code to machine code line-by-line during execution, offering more flexibility during development phases but usually resulting in slower execution times . This conversion step is necessary because a computer's CPU can only execute machine code - the binary instructions that correspond directly to the processor's architecture . To perform any operations, human-readable high-level code must be translated into this form .

Java and Python serve different strengths and typical applications in software development. Java is an object-oriented, platform-independent language that is commonly used in Android development and enterprise applications such as banking, where stability, scalability, and security are paramount . Its robustness and architecture neutrality make it ideal for large-scale industrial operations. Conversely, Python is a high-level, interpreted language known for its simplicity and readability, making it a popular choice in data science, automation, and web development . Its rich set of libraries and frameworks accelerates development in fields requiring rapid iteration and deployment. Though slower in execution compared to Java, Python's ease of use and versatility in scripting and data handling give it a significant edge in research and development environments .

Key features that make a programming language 'good' include simplicity and readability, portability, efficiency, robustness, and maintainability . Simplicity and readability ensure that code is easy to understand and write, reducing errors and improving collaboration between developers. Portability allows programs to be run on different devices without modification, broadening the software's usability. Efficiency ensures that the program runs with minimal resource consumption. Robustness contributes to handling errors gracefully and ensuring stability, while maintainability allows for easier updating and scaling of software. These features collectively enhance the development process by improving code quality, reducing development time, and lowering maintenance costs .

Using a low-level programming language like Assembly language is advantageous when there is a need for fast execution and precise control over hardware resources. This is particularly important in embedded systems, device drivers, and real-time systems where performance and resource utilization are critical, and hardware-specific optimizations are necessary . Low-level languages allow for direct manipulation of hardware and memory, enabling the development of highly efficient software that can leverage specific instruction sets of the processor .

Object-oriented programming (OOP) in C++ enhances software development by organizing code into modular, reusable units called objects, which model real-world entities and improve code management. The main principles of OOP include encapsulation, inheritance, and polymorphism . Encapsulation involves bundling data and methods that operate on the data within a single unit, or class, restricting direct access to some of the object's components. Inheritance allows new classes to inherit fields and methods from existing classes, promoting code reuse and hierarchy creation. Polymorphism enables objects to be treated as instances of their parent class, allowing for flexibility and the ability to override methods . These principles facilitate modular, maintainable, and scalable software development by allowing developers to build upon existing code and create flexible, dynamic systems .

Scripting languages, such as JavaScript, PHP, and Python, are designed to automate tasks and enhance the interactivity and functionality of web applications. They are usually interpreted rather than compiled, allowing for rapid development and deployment . In web development, JavaScript runs in browsers to create dynamic content, enhancing the user's interactive experience . PHP is employed server-side to generate dynamic web pages and manage server tasks . Python can be used to automate repetitive tasks like data manipulation and web scraping, making it a versatile scripting tool across various applications .

You might also like