🧠 STUDY NOTES: Computer Languages & Programming
Paradigms
🔤 1. Types of Computer Languages
Computers and humans communicate using specific languages, categorized into three main
types:
🟢 1.1 Machine Language (1GL)
● Definition: The lowest-level language, using binary (0s and 1s).
● Machine-dependent: Works only on specific hardware.
● No translator needed: Directly executed by the CPU.
● Example: Character 'a' = 01100001
✅ Advantages:
● Very fast execution.
● No compilation or interpretation needed.
❌ Disadvantages:
● Hard to write and debug.
● Not portable (platform-specific).
🟡 1.2 Assembly Language (2GL)
● Definition: Low-level language using mnemonics (e.g., MOV, ADD).
● Requires an Assembler to convert to machine code.
● Easier than machine language but still hardware-dependent.
✅ Advantages:
● Easier to understand and debug than machine code.
❌ Disadvantages:
● Still machine-dependent.
● Requires knowledge of mnemonics.
🔵 1.3 High-Level Language (HLL)
● Closer to human language (e.g., int x = a + b;).
● Requires a compiler or interpreter for execution.
● Portable and problem-oriented.
Types:
● 3GL (e.g., C, Java): Uses English-like syntax and arithmetic operators.
● 4GL (e.g., SQL, MATLAB): Focuses on what to do, not how.
● 5GL (e.g., Prolog, Mercury): Visual, used in AI and expert systems.
✅ Advantages:
● Easy to learn and use.
● Portable across systems.
● Easier maintenance and development.
❌ Disadvantages:
● Slower due to translation.
● May produce less efficient machine code.
🔁 Comparison Table:
Feature Machine Language Assembly Language High-Level Language
Code Type Binary (0s & 1s) Mnemonics English-like
Translator ❌ ✔ Assembler ✔ Compiler/Interpreter
Needed
Portability ❌ ❌ ✔
Machine-dependent Machine-dependent Machine-independent
Ease of Use ❌ Difficult 😐 Moderate ✔ Easy
🧩 2. Source Code vs Object Code
● Source Code: Written by the programmer (in HLL).
● Object Code: Machine language version after compilation.
Compiler: Translates entire source code at once.
Interpreter: Translates and runs one line at a time.
💡 PROGRAMMING PARADIGMS
🧭 1. Procedure-Oriented Programming (POP)
● Top-down approach: Focuses on procedures/functions.
● Examples: BASIC, FORTRAN, COBOL.
✅ Advantages:
● Easy to follow.
● Less memory use.
● Reusable algorithms.
❌ Disadvantages:
● Less secure (global data access).
● Not suitable for complex real-world modeling.
● Harder to maintain for large projects.
🧱 2. Object-Oriented Programming (OOP)
● Bottom-up approach: Focuses on data (objects), not procedures.
● Programs are organized into classes and objects.
● Examples: Java, C++, Python, C#.
4 Pillars of OOP:
1. Encapsulation – Hides data within objects.
2. Abstraction – Shows only essential features.
3. Inheritance – Reuse of code from existing classes.
4. Polymorphism – Same function behaves differently in different contexts.
✅ Advantages:
● Reusability of code.
● Better data security.
● Easier to maintain and scale.
● Real-world modeling.
❌ Disadvantages:
● Needs more planning.
● Slower execution.
● Requires more memory.
● More lines of code.
🔄 POP vs OOP Comparison:
Feature POP OOP
Approach Top-down Bottom-up
Focus Functions/Procedures Data/Objects
Security Less secure More secure
Code Reusability Limited High (via Inheritance)
Real-world modeling Not effective Very effective
Examples C, FORTRAN Java, C++, Python