1.2.4: Types of Programming Language Flashcards
What is Machine Code?
- Closest to what actually happens in a computer
- Programs directly in 1’s and 0’s
- Least abstract
- Translate directly into matching electrical signals: 1 for high voltage, 0 for low voltage
What is Assembly Language?
- Next level up from Machine Code
- Uses mnemonics so easier to use than Machine Code
- Each mnemonic matches a specific sequence of binary
- One-to-one relationship
- Written in Assembly Language and translated by a specific assembler
What are High-Level Languages?
- First languages that could go further than Machine Code and Assembly Language (First developed in the early 50’s, starting with Fortran)
- One-to-many relationship, as each instruction could give rise to many lines of Machine Code
What are Programming Paradigms?
- Different approaches to using programming language to solve a problem
How do you decide what Paradigm to use?
- Depends on the type of problem that needs solving
What is Imperative Programming?
- The use of code that clearly specifies the actions performed
What is Procedural Programming?
- One of the most widely-used paradigms
- Uses a sequence of instructions which may be contained within procedures
- Instructions are carried out in a step-by-step manner
What is Procedural Programming used for?
- A wide range of software development as it is easy to implement
What is a drawback of Procedural Programming?
- It is not possible to solve all kinds of problems with Procedural Languages, or it may be inefficient to do so
What are the advantages of Procedural Programming?
- Can be applied to a wide range of problems (that can easily be expressed as a series of instructions)
- Is relatively easy to write and interpret
What do Procedural Languages use?
- Traditional data types such as integer and strings which are built into the language and also provide data structures like dictionaries and arrays
What is Object-Oriented Programming?
- Applicable to certain types of problem with lots of reusable components with similar characteristics
- Built on entities (Objects) formed from Classes with certain Attributes and Methods
What is the main focus of Object-Oriented Programming?
- Making programs that are reusable and easy to update and maintain
What is the focus of Declarative Programming?
- Stating the desired result rather than the exact series of instructions that need to be performed to get the result
- It is the role of the programming language to determine how to best obtain the result
- The details about how the result is obtained are abstracted from the user
- Common programming in expert systems and AI
What is Functional Programming?
- The concept of reusing a set of functions that form the core of the program
- Programs are made up of lines of code consisting of function calls, often combined within each other
- Closely linked to Maths
What are Logic Languages?
- The use of code which defined a set of facts and rules based on the problem
- Queries are used to find answers to problems
What is Structured Programming?
- A popular subsection of Procedural Programming in which the control flow is given by four main programming structures
What are the four main programming structures in Structured Programming?
- Sequence
- Selection
- Iteration
- Recursion
What is Sequence?
- Code is executed line-by-line, top to bottom
What is Selection?
- A certain block of code is run if a specific condition is met [IF statements]
What is Iteration?
- A block of code is executed a certain amount of times or while a condition is met [FOR, WHILE, or REPEAT UNTIL loops]
What is Recursion?
- Functions are expressed in terms of themselves and are executed calling themselves until a certain condition (base case that does not call the function) is met
What is ADD in LMC?
- Instruction: ADD
- Add the contents of the memory address to the Accumulator
What is SUB in LMC?
- Instruction: SUBTRACT
- Subtract the contents of the memory address from the Accumulator
What is STA in LMC?
- Instruction: STORE
- Stores the value in the Accumulator into the memory address given
What is LDA in LMC?
- Instruction: LOAD
- Load the Accumulator with the contents of the memory address given
What is BRA in LMC?
- Instruction: BRANCH ALWAYS
- Branch - Use the next address given as the address of the next instruction
What is BRZ in LMC?
- Instruction: BRANCH IF ZERO
- If the Accumulator is zero, branch to the address given
What is BRP in LMC?
- Instruction: BRANCH IF POSITIVE
- If the Accumulator is positive or zero, branch to the address given
What is INP in LMC?
- Instruction: INPUT
- Input into the Accumulator
What is OUT in LMC?
- Instruction: OUTPUT
- Output the contents of the Accumulator
What is HLT in LMC?
- Instruction: HALT
- Stops the execution of the program
What is DAT in LMC?
- Instruction: DATA
- Used to indicate a location that contains data
What are Machine Code instruction made up of?
- Operand and Opcode
What is the Operand?
- Holds a value which is related to the data on which the instruction is to be performed
What is the Opcode?
- Specifies the instructions to be performed
What does the Addressing Mode do?
- Specifies how the Operand should be interpreted
What is Immediate Addressing?
- The Operand is the actual value upon which the instruction is to be performed, represented in binary
What is Direct Addressing?
- The Operand gives the address which holds the value upon which the instruction is to be performed (Used in LMC)
What is Indirect Addressing?
- The Operand gives the address of a register which holds another address, where the data is located
What is Indexed Addressing?
- An index register is used, which stores a certain value
- The address of the Operand is determined by adding the Operand to the index register
- This is necessary to add an offset in order to access the data stored contiguously in memory such as in arrays