Concepts of Programming Languages

Concepts of Programming Languages

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

Implicit Heap-Dynamic Variables

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (115)

Section 1

(50 cards)

Implicit Heap-Dynamic Variables

Front

variables that are bound to heap storage only when they are assigned values highest degree of flexibility disadvantage is the run time overhead of maintaining all the dynamic attributes another disadvantage is the loss of some error detection by the compiler

Back

Token

Front

category of lexemes

Back

Explicit Declaration

Front

statement in a program that lists variable names and specifies that they are a particular type

Back

Ambiguity in Grammars

Front

grammar is ambiguous iff it generates derivation that has two or more distinct parse trees

Back

Syntax

Front

form or structure of the expressions, statements, and program units

Back

Influences on Language Design

Front

1. computer architecture (languages are developed around the von Neumann architecture, fetch-execute cycle) 2. programming methodologies (e.g., OOP)

Back

Reliability

Front

conformance to specifications 1. type checking 2. exception handling 3. aliasing 4. readability and writability

Back

Deallocation

Front

process of placing a memory cell that has been unbound from a variable back into the pool of available memory

Back

Compilation

Front

translation from high-level language to machine language slow translation, fast execution

Back

JIT Compiler

Front

a hybrid between a compiler and an interpreter. the code is reasonably compiled, usually in pieces when it is needed, and saved so that it can be reused later.

Back

Rule

Front

has a left-hand side (LHS), which is a nonterminal, and a right-hand side (RHS), which is a string of terminals and/or nonterminals e.g. <id> -> identifier | identifier <arithmetic_operator> identifier

Back

Linking and Loading

Front

process of collecting system program units and linking them to a user program

Back

Writability

Front

ease with which a language can be used to create programs 1. simplicity and orthogonality 2. support for abstraction 3. expressivity

Back

Derivation

Front

repeated application of rules, starting with the start symbol and ending with a sentence (all terminal symbols)

Back

Binding Times

Front

time at which a binding takes place language design time, language implementation time, compile time, load time, link time, run time

Back

Elaboration

Front

storage allocation and binding process indicated by the declaration, which takes place when execution reaches the code to which the declaration is attached. Occurs during run time

Back

Cost

Front

ultimate total cost of using a language 1. training others to use the language 2. writing programs 3. compiling programs 4. executing programs 5. language implementation system 6. reliability (poor reliability increases costs) 7. maintenance

Back

Alias

Front

when more than one variable name can be used to access the same memory location

Back

Preprocessor Macro

Front

specifies code from another file is to be included e.g. C #include

Back

Top Down Parser

Front

produce parse tree beginning at the root left-most derivation builds the parse tree in preorder

Back

Type Inference

Front

type of implicit type declaration that uses context

Back

Static Variables

Front

variables that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates

Back

Four Criteria

Front

readability, writability, reliability, cost

Back

Lifetime of a Variable

Front

time during which the variable is bound to a specific memory location

Back

Start Symbol

Front

special element of the nonterminals of a grammar

Back

Explicit Heap-Dynamic Variables

Front

nameless (abstract) memory cells that are allocated and deallocated by explicit run time instructions written by the programmer. Variables can only be referenced through pointer or reference variables

Back

Reserved Word

Front

special word that cannot be used as a user-defined name

Back

Semantics Analysis

Front

generate intermediate code

Back

Functional Languages

Front

main means of making computations is by applying functions to given parameters e.g. LISP, Scheme

Back

Static Binding

Front

occurs before run time and remains unchanged throughout program execution

Back

Readability

Front

ease with which programs can be read and understood 1. overall simplicity 2. orthogonality (a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language) 3. data types 4. syntax considerations

Back

Scope

Front

scope of a variable is the range of statements in which the variable is visible

Back

Stack-Dynamic Variables

Front

variables whose storage bindings are created when their declaration statements are elaborated, but whose types are statically bound

Back

Semantics

Front

meaning of the expressions, statements, and program units

Back

Dynamic Binding

Front

occurs during execution or can change during execution of the program disadvantages include reduced error-detection capability -- incorrect right sides of assignment statements are not detected, rather the type of the left side is changed to the incorrect type another disadvantage is cost -- requires considerable execution time, type checking must be done at run time, and every variable must hve a run time descriptor associated with it to maintain the current type languages with dynamic binding are typically interpreter rather than compiled

Back

Type

Front

range of values the variable can store and the set of operations that are defined for values of that type

Back

Binding

Front

association between attribute and entity, such as between a variable and its type of value, or between an operation and symbol

Back

Terminals

Front

lexemes or tokens

Back

Grammar

Front

finite non-empty set of rules

Back

Logic Languages

Front

rule-based e.g. Prolog

Back

Local Variable

Front

variable that is declared in a program unit or block

Back

Bottom Up Parser

Front

produce parse tree beginning at the leaves reverse of a right-most derivation

Back

Von Neumann Bottleneck

Front

Connection speed between a computer's memory and its processor determines the speed of a computer Program instructions often can be executed much faster than the speed of the connection; the connection speed thus results in a bottleneck

Back

Imperative Languages

Front

central features are variables, assignment statements, and iteration abstraction of von Neuman architecture e.g. C, Java, Perl, JavaScript, .NET, C++

Back

Implicit Declaration

Front

associates variables with types through default conventions rather than declaration statements

Back

Variable

Front

abstraction of a memory cell sextuple of attributes: name address value type lifetime scope

Back

Allocation

Front

process by which a memory cell, which is bound to a variable, is taken from a pool of available memory

Back

Pure Interpretation

Front

easier implementation, run-time errors easily and immediately displayed slower execution

Back

Visibility

Front

variable is visible in a statement if it can be referenced in that statement

Back

Code Generation

Front

machine code is generated

Back

Section 2

(50 cards)

Compatible Type

Front

type that is either legal for the operator or is allowed under language rules to be implicitly converted, by compiler-generated code, to a legal type automatic conversion is called coercion

Back

Heap-Dynamic Array

Front

array in which the binding of subscript ranges are storage allocation is dynamic and can change any number of times during the array's lifetime advantage is flexibility -- arrays can grow and shrink during program execution as the need for space changes disadvantage is that allocation and deallocation take longer and may happen many times during execution of the program

Back

Stack-Dynamic Array

Front

array in which both the subscript ranges and the storage allocation are dynamically bound at elaboration time; once ranges are bound and storage is allocated, they remain fixed during lifetime of the variable advantage is flexibility; size not need be known until array is about to be used

Back

Mark-Sweep Approach

Front

system allocates and deallocates pointers as necessary, doesn't reclaim and allows garbage to accumulate once all cells allocated, mark-sweep process begins and gathers all garbage left in heap every heap cell has indicator bit used by collection algorithm 1. all cells have bits set to indicate garbage or not garbage 2. marking phase - every pointer in program traced into heap, and all reachable cells marked as not garbage 3. sweep - all cells in the heap that have not been marked are returned to list of available space lazy approach

Back

Record

Front

possibly heterogeneous aggregate of data elements in which the individual elements are identified by names

Back

Associative Array

Front

unordered collection of data elements that are indexed by an equal number of values called keys aka map, dictionary

Back

Value Type Variable

Front

variable used to store data

Back

Reference Type

Front

variable similar to pointer, but references an object or a value in memory rather than the memory address

Back

Lost Heap-Dynamic Variable, Memory Leak

Front

an allocated heap-dynamic variable that is no longer accessible to the user program, also known as garbage or a memory leak 1. Pointer p1 is set to point to a newly created heap-dynamic variable. 2. p1 is later set to point to another newly created heap-dynamic variable.

Back

Array

Front

homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate, relative to the first element

Back

Subrange Type

Front

contiguous subsequence of an ordinal type e.g. 12...14 is a subrange of integer type

Back

Global Variable

Front

a variable that is visible to every module in the program

Back

Heterogeneous Array

Front

array in which the elements need not be of the same type

Back

Dynamic Scoping

Front

based on the calling sequence of subprograms, not on their spatial relationship to each other. Thus, the scope can be determined only at run time disadvantages include difficulty in reading, inability to type check references to nonlocals statically, and the local variables of the subprogram during execution are all visible to any other executing subprograms regardless of proximity or how execution got to the executing subprogram

Back

Pointer

Front

type in which the variables have a range of values that consist of memory addresses

Back

Union

Front

type whose variables are allowed to store different type values at different times during execution

Back

Fixed Stack-Dynamic Array

Front

array in which the subscript ranges are statically bound, but the allocation is done at declaration elaboration time during execution. advantage over static is space efficiency; large array in one subprogram can use the same space as a large array in a different subprogram as long as both subprograms are not active at the same time disadvantage is the required allocation and deallocation time

Back

Referencing Environment

Front

collection of all variables that are visible in the statement reference collection of a statement in a static-scoped language is the variables declared in its local scope plus the collection of all variables of its ancestor scopes that are visible

Back

Character String Type

Front

type in which the values consist of sequences of characters

Back

Static Ancestors

Front

static parent(s) up to the largest enclosing subprogram

Back

Nonlocal variable

Front

variable that is visible but not declared within the program unit or block

Back

Jagged Array

Front

array in which the length of the rows need not be the same

Back

Heap

Front

area where storage is dynamically allocated

Back

Object

Front

instance of a user-defined (abstract) data type

Back

Limited Dynamic Length String

Front

strings allowed to have varying length up to a declared and fixed maximum set by the variable's definition C, C++ Descriptor (run time descriptor to store both fixed maximum length and the current length): name (limited dynamic string) maximum length current length address of first character

Back

Fixed Heap-Dynamic Array

Front

similar to fixed stack-dynamic in that subscript ranges and storage binding are both fixed after storage is allocated differences are that both are done when the user program requests them during execution and storage is allocated from the heap advantage is flexibility -- array's size always fits the problem disadvantage is allocation time from heap, which is longer than from the stack

Back

Static Scoping

Front

method of binding names to nonlocal variables. Scope of variable can be statically determined prior to execution, e.g., by human reader

Back

Anonymous Variables

Front

variables without names

Back

Ordinal Type

Front

type in which the range of possible values can be easily associated with the set of positive integers

Back

Reference Type Variable

Front

variable used to reference some other variable

Back

Column Major Order

Front

used to access multi-dimensional arrays by columns given matrix [1 2] [3 4] addresses are 0 = 1, 1 = 3, 2 = 2, 3 = 4 used by Fortran

Back

Static String Length

Front

length is static and set when the string is created Java, Python Descriptor (required only during compilation): name (static string) length address of first character

Back

Row Major Order

Front

used to access multi-dimensional arrays by rows given matrix [1 2] [3 4] addresses are 0 = 1, 1 = 2, 2 = 3, 3 = 4

Back

Primitive Data Types

Front

reflections of the hardware, like integer types. Some require non-hardware support for implementation

Back

Block

Front

languages that allow new static scopes to be defined in the midst of executable code stack dynamic so storage is allocated when section is entered and deallocated when section is exited int counter; while (...) { int counter; //new static scope counter++; }

Back

Static Array

Front

array in which the subscript ranges are statically bound and storage allocation is static (done before run-time) advantage is efficiency; no dynamic allocation or deallocation is required disadvantage is that the storage for the array s fixed for the entire execution time of the program

Back

Static Parent

Front

subprogram that declares a subprogram

Back

Data Type

Front

collection of data objects and a set of predefined operations on those objects

Back

Dangling Pointer/Reference Definition, Dangers, Creation

Front

pointer that contains the address of a heap-dynamic variable that has been deallocated dangerous because: 1. location may have been reallocated to new variable 2. could destroy value of new variable int * arrayPtr1; int * arrayPtr2 = new int[100]; arrayPtr1 = arrayPtr2; delete [] arrayPtr2; // Now, arrayPtr1 is dangling, because the heap storage // to which it was pointing has been deallocated.

Back

Named Constant

Front

variable that is bound to a value only once e.g. pi

Back

String Design Issues

Front

Special kind of character array, or primitive type? Static or dynamic length?

Back

Heap-Dynamic Variables

Front

variables that are dynamically allocated from the heap, often do not have identifiers associated with them and can be referenced only by pointer or reference variables

Back

Enumeration Type

Front

type in which all of the possible values, which are named constants, are provided in the definition provides a way of defining and grouping collections of named constants e.g. enum days { Mon, Tues,..., Fri}; where the days are implicitly assigned integer values 1...n

Back

Dynamic Length Strings

Front

varying length with no maximum JavaScript requires overhead of dynamic storage allocation and deallocation, but provides most flexibilty Descriptor (run time descriptor to store current length): current length

Back

Reference Counters

Front

counter that stores number of pointers currently pointing at a cell. When counter reaches zero, cell has become garbage and can be deallocated eager approach

Back

Slice

Front

substructure of an array; nothing more than a referencing mechanism

Back

Rectangular Array

Front

multi-dimensional array in which all of the rows have the same number of elements and all columns have the same number of elements model tables exactly

Back

Descriptor

Front

collection of the attributes of a variable

Back

Accessing Array (1d)

Front

address(list[k]) = address(list[lower_bound]) + ((k - lower_bound) * element_size) address of list[1] = address of list[0] + (1 - 0) * element_size address of list[1] = address of list[0] + 1 * element_size off by one -- no need for subtraction when lower bound is zero

Back

Type Checking

Front

activity of ensuring that the operands of an operator are of compatible types

Back

Section 3

(15 cards)

Dynamic Type Checking

Front

done at run time and must be done if type bindings are dynamic

Back

Statically typed language

Front

Data and programs stored in memory Memory is separate from CPU Instructions and data are piped from memory to CPU Basis for imperative languages Variables model memory cells Assignment statements model piping Iteration is efficient

Back

Smalltalk

Front

product of research led by Alan Kay at Xerox Palo Alto Research Center, object-oriented, dynamically typed, reflective programming language, Simula-like class inheritance model of execution, everything is an object

Back

Algol

Front

ALGOrithmic Language, mid-1950s, rise to BCPL, B, Pascal, PL/I, Simula, C and more. Developed jointly by a committee of European and American computer scientists in a meeting in 1958, Three different syntaxes: a reference syntax, a publication syntax, and an implementation syntax

Back

Name Type Equivalence

Front

equivalence where two variables have equivalent types if they are defined either in the same declaration or in declarations that use the same type name

Back

Simula

Front

By Ole-Johan Dahl and Kristen Nygaard in 1960s, first object-oriented programming language, simulating discrete event systems, SIMULA standardized by Standards Group in Feb 1968.

Back

Structural Type Equivalence

Front

equivalence where two variables have equivalent types if their types have identical structures

Back

Static Type Checking

Front

can be done if type bindings are static

Back

mixed mode expressions

Front

INTEGER operands are always converted to REAL before carrying out any computations. As a result, the result of a mixed mode expression is of REAL type. Simple Examples: 1 + 2.5 is 3.5 1/2.0 is 0.5 2.0/8 is 0.25

Back

Referential transparency

Front

Referential transparency is an oft-touted property of (pure) functional languages, which makes it easier to reason about the behavior of programs. I don't think there is any formal definition, but it usually means that an expression always evaluates to the same result in any context.

Back

Strongly Typed

Front

language is considered strongly typed if type error are always detected, requires type of all operands to be determined either at compile time or run time

Back

Type Equivalence

Front

types are equivalent if an operand of one type in an expression is substituted for one of the other type, without coercion

Back

Type Error

Front

application of an operator to an operand of an inappropriate type

Back

Dynamically typed languages

Front

Do not enforce or check typesafety at compile-time, deferring such checks until run-time

Back

C

Front

By Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs; Systems programming; Unix written in C; standardized by the American National Standards Institute and International Organization for Standardization; imperative (procedural) language; not initially designed with portability in mind.

Back