CPL Test 1

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/73

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

74 Terms

1
New cards

reasons for studying concepts of programming languages

express ideas, choosing appropriate languages, increased ability to learn new languages, better understanding of significance of implementation, better use of languages that are already known, overall advancement of computing.

2
New cards

programming domains

scientific applications (Fortran), Business applications (COBOL), Artificial intelligences (LISP), Systems programming (C), web software (HTML, PHP, Java Script)

3
New cards

von neumann architecture

data and programs stored in memory, memory is separate from CPU, instructions and data are piped from memory to CPU, basis for imperative languages

4
New cards

language categories

imperative, functional, logic, markup or hybrid

5
New cards

imperative language

uses a sequence of statements to change a programs state and achieve some goal. includes variables, assignment statements, and iteration. supports object-oriented programming. include scripting languages. include visual languages. Ex: C, Java, Perl, JavaScript, Visual BASIC .NET, C++

6
New cards

functional language

Approaches computation as a process of applying functions to given parameters. Ex: LISP, Scheme, ML, F#, Miranda

7
New cards

logic language

a declarative programming language that expresses programs as sets of facts and logical rules, allowing computers to perform computations based on formal logic rather than step-by-step instructions. Ex: Prolog

8
New cards

Markup/programming hybrid

a system for adding annotations (tags or codes) to a document to describe its structure, presentation, and meaning, allowing computers to interpret and display the content correctly. Ex: JSTL, XSLT, HTML, LaTeX

9
New cards

language evaluation criteria

readability (most important), writability, reliability, cost. all interdependent on one another (ex readability can improve reliability by making it harder for programmers to misunderstand)

10
New cards

compilation

programs are translated into machine language. slow translation, fast execution; includes JIT systems. use on large commerfical applications

11
New cards

pure interpretation

programs are interpreted by another program known as an interpreter; python. use on small programs or when efficiency is not an issue

12
New cards

hybrid implementation system (compilation and interpretation)

compromise between compilers and pure interpreters. small and medium when efficiency is not the first concern. Ex: Perl

13
New cards

phases of compilation

lexical analysis: converts characters in the source program into lexical units. syntax analysis: transforms lexical units into parse trees which represent the sytantic structure of program. semantics analysis: generate intermediate code. code generation: machine code is generated.

14
New cards

von neumann bottleneck

connection speed between a computer’s memory and its processor determine the speed of a computer, though program instructions can often be executed much faster. This is the primary limiting factor in the speed of computers

15
New cards

Preprocessors

preprocess macros are commonly used to specify code from another file is to be included. processes a program immediately before the program is compiled to expand embedded preprocessor macros.

16
New cards

readability

the ease with which programs can be read and understood. simplicity/orthogonality, control structures, data types and structures. (maybe expressivity)

17
New cards

writability

the ease with which a language can be used to create programs. simplicity/orthogonality, control structures, data types and structures, syntax design, support for abstraction, expressivity.

18
New cards

reliability

conformance to specification. simplicity/orthogonality, control structures, data types adn structures, syntax design, support for abstraction, expressivity, tpe checking, exception handling, restrict aliasing. 

19
New cards

cost

the ultimate total cost. development, maintenance and reliability most important criteria

20
New cards

orthogonality

means that a relatively small set of primitve constructs can be combined in a relatively small number of ways to build the control and data structures of the language. Closely related to simplicity. need a happy medium. too many rule exceptions leads to non-readability. too much orthogonality would allow for weird applications of the rules.

21
New cards

power of a language

the ability to express requests in very few symbols

22
New cards

other evaluation criteria

portability: ease with which programs can be moved from one implementation to another (degree of standardization of the language), generality: applicability to a wide range of applications, well-definedness: completeness and precission of the language’s official definition.

23
New cards

two pass compilers

go through a first pass to find functions defined after they are used. In the second pass use the functions it found and incorporate them into the program where they are used.

24
New cards

one pass compilers

only go through the code once so functions must be defined before they are used.

25
New cards

APL

a programming lanfuage. interpreted language with dynamic typing. very powerful language. expressions evaluate right to left.

26
New cards

lazy evaluation

evaluation strategy which delays the evaluation of an expression until its value is needed

27
New cards

standard way to publish algorithms for over 20 years

ALGOL 60

28
New cards

ALGOL

the primary first imperative language. “mother of all imperative languages”. all subsequent imperative languages are derived from ALGOL

29
New cards

pessimal algorithms

the absolute worst version of an algorithm you can come up with

30
New cards

four abstraction concepts used in sematic data models (such as EER)

classification and instantiation, identification, specialization and generalization, aggregation and association.

31
New cards

syntax

the form or structure of the expressions, statements, and program units (is it written correctly)

32
New cards

semantics

the meaning of the expressions, statements, and programs (what does it mean)

33
New cards

sentence

a legal string of characters over some alphabet

34
New cards

language

a set of sentences

35
New cards

lexeme

the lowest level syntactic unit of a language (ex *, sum, begin)

36
New cards

token

a category of lexemes (ex identifier)

37
New cards

lexemes and tokens in: index = 2 * Count + 17;

lexemes: =, 2, *, Count, +, 17, ;.  tokens: identifier, equal_sign, int_literal, mult_op, identifier, plus_op, Int_literal, semicolon (match with the lexemes)

38
New cards

what determines the order of operations

the grammar

39
New cards

recognizer

tokenizer. reads input strings over the alphabet of the language and decides whether the input strings belong to the language.

40
New cards

generator

device that generates sentences of a language. one can determine if the syntax of a particular sentence is syntactically correct by comparing it to the structure of the generator.

41
New cards

backus-naur form

equivalent to context free grammars. an example of a metalanguage.

42
New cards

derivations

every string of symbols in a derivation is a sentential form. A sentence is a sentential form that has only terminal symbols. A leftmost derivation is one in which the leftmost nonterminal in each sentential form is the one that is expanded. A derivation could be either leftmost or rightmost or mixed (mixed is impractical).

43
New cards
<p>What is the language of this grammar?</p>

What is the language of this grammar?

L = {anbn | n >= 0}

44
New cards

nonterminal symbols

symbols that can be defined with other symbols. set represented by N. (has something to the right of the arrow)

45
New cards

terminal symbols

symbols that are fully defined on their own. set represented by sigma. (will not be defined by something to the right of the arrow)

46
New cards

Regular grammars

productions must be of the form A → xB, where A and B are nonterminal symbols and x is a string of terminal symbols

47
New cards

context-free grammars

productions must be of the form A → alpha, where A is nonterminal symbol and alpha is a string of terminals and nonterminals in any order (essentially the same as BNF grammar)

48
New cards

context-sensitive grammars

productions must be of the form alpha → beta where alpha and beta are strings of terminals and nonterminals with the restriction that the number of symbols in alpha may not exceed the number of symbols in beta.

49
New cards

unrestricted grammars

production rules are of the form alpha → beta with no restrictions (problems figuring out exactly how to go about things)

50
New cards
<p>What is the language of this grammar?</p>

What is the language of this grammar?

L = { anbncn | n >= 1}

51
New cards

six attributes of a variable

name, address, value, type, lifetime, scope

52
New cards

name (variable)

maximum length? are connector characters allowed? are names case sensitive? are special words reserved words or keywords?

53
New cards

address (variable)

the memory at which a variable is located. may have different addresses at different times in execution or at different places in a program.

54
New cards

value (variable)

the contents of the location at which the variable is associated

55
New cards

type (variable)

determines the range of values of variables and the set of operations that are defined for values of that type; in the case of floating point, type also determines precision

56
New cards

alias

two different variable names that refer to the same memory location. changes made through one affect the other. can cause side effects or confusion in programs.

57
New cards

binding

an association between an entity and an attribute, such as between a variable and its value, or between an operation and a symbol. binding time is the point at which binding takes place.

58
New cards

possible binding times

language design time, language implementation time, compile time, load time, runtime

59
New cards

language design time binding

language features are decided by the language designer and certain symbols bound to certain actions by the language’s grammar (* being multiplication for example)

60
New cards

language implementation time binding

details of how the language works are fixed by the compiler/interpreter implementer (ex defining that int uses 32 bits)

61
New cards

compile time binding

When the program you wrote is translated into machine code. The compiler checks types, resolves static bindings, and lays out code and data structures. (binding a variable to a type and checking that + is used correctly for the types involved)

62
New cards

load time binding

when the compiled program is loaded into memory for execution, binding occurs. (assigning static variables to actual memory addresses)

63
New cards

runtime binding

when the program is actively running and dynamic bindings happen (assign local variables to memory on the stack, resolving virtual method calls, or handling dynamic typing in languages like Python)

64
New cards

static vs. dynamic binding

a binding is static if it first occurs before run time and remains unchanged throughout program execution. A binding is dynamic if it first occurs during execution or can change during execution of the program.

65
New cards

explicit vs. implicit declaration

explicit declaration is a program statement used for declaring the types of variables (int i). implicit declaration is a default mechanism for specifying types of variables through default conventions, rather than declaration statements (python just uses whatever the variable is assigned to determine its type)

66
New cards

variant record

used in Ada. a variable with variants depending on a discriminant tag. only one variant’s fields are active at a time allowing the program to save space.

67
New cards

overlay

variants that share the same space in memory. can only have one active variant at a time. used to conserve memory.

68
New cards

ambiguous vs. unambiguous grammars

an ambiguous grammar allows more than one parse tree for the same string, whereas an unambiguous grammar has exactly one parse tree per valid string.

69
New cards

operator presedence specified in a grammar

expression has the lowest precedence because it relies on the evaluation of term.
term has higher precedence because it can still rely on factor.
it seems circular (since factor may rely on an expression), but the whole expression can be enclosed in parentheses and treated as a single factor — making it a subproblem. factor still must be evaluated first.

<p>expression has the lowest precedence because it relies on the evaluation of term.<br>term has higher precedence because it can still rely on factor.<br>it seems circular (since factor may rely on an expression), but the whole expression can be enclosed in parentheses and treated as a single factor — making it a subproblem. factor still must be evaluated first.</p>
70
New cards

operator associativity

defines how operators of the same precedence are grouped (think the addition and subtraction part of PEMDAS). could be left to right or right to left for example. ensures consistent parsing when multiple operators of equal precedence appear.

71
New cards

important things about Miranda

a purely functional programming language, meaning you ask the program to do something without specifying how to do it. uses lazy evaluation (only computes what is necessary), has a strong type system that helps catch errors early, no side effects in that functions always give the same result for the same input, and uses lists and function definitions instead of loops.

72
New cards

FORTRAN equivalence / unions / isub

older languages like FORTRAN (equivalence) and C (unions) and PL/I (isub) used equivalence and overlays to reuse memory for different variables or data types.

73
New cards

reserved vs. keywords

a reserved word is one that cannot be used by a programmer as an identifier and keywords are words that have predefined special meaning within the syntax of the language.

74
New cards

language design trade-offs

reliability vs. cost of execution, readability vs writability, writability vs reliability