Programming languages
Programming Languages
Types of Programming Languages
High-Level Languages:
Examples: Python, Java, C++.
Made up of human-readable statements, easier for programmers.
Must be converted to machine code for computer processing.
Low-Level Languages:
Example: Machine code.
Machine code is the only form the CPU can process directly.
Conversion is done by a translator.
Conversion Process of Programming Languages
Programs written in high-level languages need translation:
Translator Types:
Interpreters
Compilers
Assemblers
Characteristics of Programming Languages
High-Level Languages Characteristics:
Human-readable, must be translated for CPU execution.
Generally portable across different CPU types.
One statement can represent multiple CPU instructions.
Low-Level Languages Characteristics:
More difficult for humans to read.
Provide precise control over CPU.
Executable only on specific CPU types.
Faster execution, no translation overhead required.
Examples of Programming Languages
Interpreted Languages:
Python, JavaScript - interpreted every time.
Compiled Languages:
C, C++ - compiled into an executable file.
Assembly Language:
Assembled into machine code, requiring understanding of CPU operations.
Assembly Language
Definition: A low-level language using mnemonics for instructions.
Each CPU has an Instruction Set that assembly language maps to.
Mnemonic example: ADD for addition instead of binary instruction.
Easier than machine code but requires knowledge of CPU architecture.
Example of Assembly Language
Assembly code snippet:
Contains human-readable mnemonics and comments to explain functionality.
Example:
MOV ECX, -1stores a value in a register.
Purpose of Translators
Essential software that converts high-level code to machine code.
Translation Process:
Input: Source code in high-level language.
Output: Machine code executable by CPU.
Types of Translators
Assemblers: Converts assembly language to machine code.
Requires deep technical knowledge of CPU.
Rarely used today except for specific cases like hardware drivers.
Compilers: Converts the entire high-level code at once.
Produces an executable file (.exe).
Compiled code runs faster as there is no repeated translation.
Interpreters: Translates high-level code one line at a time.
Slower in execution but easier for debugging.
Portable across different CPU platforms.