Introduction to programming - nature of programming languages
compiler
A program that translates source code written in a high-level programming language into machine code that can be executed by a computer.
interpreter
A program that translates and executes code from a high-level programming language line-by-line, without producing a separate executable file.
What are the fundamental operations of a computer
The basic actions performed by the CPU as part of its instruction set, including operations such as add (performing arithmetic addition), compare (evaluating conditions), retrieve (fetching data from memory), and store (saving data to memory).
Compound operations
Compound operations are complex tasks composed of many simple operations. An example is “find the largest.”
Essential Features of Computer Languages
Fixed vocabulary, unambiguous meaning, consistent grammar and syntax
Why do programming languages have a fixed vocabulary?
Consistency: A fixed vocabulary ensures that the same terms and symbols always mean the same thing, reducing ambiguity.
Efficiency: It allows compilers and interpreters to efficiently parse and translate code.
Error Reduction: Consistent use of terms minimizes the risk of errors and misunderstandings in code interpretation.
Learning Curve: A defined set of keywords and symbols makes it easier for programmers to learn and master the language.
Why do programming languages require unambiguous meaning?
This ensures that each instruction is interpreted in exactly one way, preventing errors and misunderstandings, and enabling reliable and predictable program execution.
Why do programming languages require consistent grammar and syntax?
Consistent grammar and syntax are essential to ensure that code is structured in a predictable way, making it easier to read, write, and debug. This consistency helps compilers and interpreters accurately parse and translate code into machine language.
Translator
A general term for a program that converts code from one programming language into another, including compilers and interpreters.
Virtual Machine
A software-based emulation that allows programs to run independently of the underlying hardware. This includes systems that emulate an entire physical computer and environments designed to run programs written in specific programming languages, such as the Java environment for Java programs and the Python environment for Python programs.
Low-level language
A programming language that provides little or no abstraction from a computer’s architecture. Examples include assembly language and machine code.
High-level language
A programming language that abstracts the details of the computer hardware, making it easier for humans to read, write, and maintain code. It allows for more concise expression of compound operations and complex algorithms. Examples include Python, Java, and C++.
Bytecode
A kind of instruction set, similar to machine code, but designed for efficient execution by a software interpreter or a virtual machine rather than directly by a central processing unit (CPU). Often used in high-level programming languages like Java to allow programs to run on any platform that has a compatible interpreter or virtual machine.
What are the reasons for using high-level languages?
They provide abstraction from the basic operations of the computer, making it feasible to write complex systems. They also facilitate ease of debugging, maintenance, code reuse, and modularity.
Outline the need for a translation process from a higher-level language to machine executable code
Computers can only understand and execute instructions in their native machine language. This process, done by compilers, interpreters, or virtual machines, allows the high-level instructions to be converted into machine code that the computer’s hardware can execute.