Chapter 6: Programming Languages Flashcards
First generation of programming languages
- First generation: pure machine languages (machine code)
Second generation: assembly languages
- Assembler:
- A mnemonic system for representing machine instructions:
mnemonic names for op-codes
descriptive names for memory locations (variables) chosen by the programmer - One to one correspondence between machine instructions and assembly instructions
- Inherently machine-dependent
- Assembler: convert assembly language to machine language
Third generation languages
Compiler:
- Early examples:
- Uses high level primitives
- Machine independent (mostly)
- Each primitive corresponds to a sequence of machine language instructions
- Compiler: converts third generation language to machine language
- Early examples: Fortran, Cobol
Programming paradigms
- Functional: basic building blocks: functions
- Object-oriented: basic building block: objects
- Imperative: basic building block: procedures
- Declarative, for example:
- logic programming: basic building block: logical formulas
Primitive data types
- Integer: whole numbers signed/unsigned
- Float: numbers with fractions
- Characters: symbols, 8/16 bits
- Boolean: True/False
What is array (data structure)
An array is a block of data where all elements are of the same type
What is aggregate type (data structure)
It’s a block of data where different elements can have different types
What is a variable?
En variabel är ett namngivet utrymme i primärminnet.
It’s a named location in primary memory, which can store a value.
What is a literal?
It’s a value of some type for example: 3.14
What is a constant?
It’s a named literal for example: const PI = 3.14;
Procedural units?
- Subprogram, subroutine, procedure, function, method, predicate
- Used to simplify program development by abstraction
Translation process
- Step 1:
Source Program
Step 2:
Lexical Analyzer: categorizes the codes into tokens
Step 3:
Parser: Builds data structure or abstract syntax tree
Step 4:
Code Generator: Turns into machine language
Object oriented programming
- Class:
- Object:
- Features:
- Class:
template from which objects are constructed
includes descriptions of both variables and methods (functions) - Object:
active program unit containing both data and code;
called a instance of the class, from which it is constructed - Features:
Inheritance
Encapsulation
Polymorphism
Concurrent programming
- Parallel processing:
- Thread:
- Concurrent programming: simultaneous execution of multiple processes
- Parallel processing: parallel execution of multiple processes, which requires multiple CPU cores
- Thread: concurrent/parallel execution path within the same program/process
Logic Programming
- Program consists of logical formulas (statements) in the form of rules and facts
- There is no distinction between code and data
- Built-in deduction engine using a derivation technique called resolution
- Answer question whether a fact is a logical consequence of the program or not