module 1 Flashcards
what are the categories of language evaluation criteria?
- readability
- writability
- reliability
- cost
what are languages developed around?
Von Neumann architecture
draw and describe the 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
why do we need different languages?
New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new
programming languages
what are the 4 language categories?
- imperative: variables, assignment statements, iteration, scripting, visual, and object-oriented languages (Java, C, JavaScript)
- functional: main means of making computations is by applying functions to given parameters
- logic: rule-based (prolog)
- markup/programming hybrid: markup languages extended to support some programming (JSTL)
what are the tradeoffs in language design?
reliability vs cost of execution (java demands all references to array elements to be checked for proper indexing)
readability vs writability (APL allows complex computations by containing powerful operators)
writability vs reliability (C++ pointers are powerful and flexible but unreliable)
3 implementation methods
- compilation: programs are translated into machine language (large commercial applications)
- pure interpretation: programs are interpreted by another program known as an interpreter (small programs, efficiency is not concern)
- hybrid implementation systems: compromise between compilers and pure interpreters (small and medium systems)
what are the phases of the compilation process?
- lexical analysis: converts characters in the source program into lexical units
- syntax analysis: transforms lexical units into parse trees
- semantics analysis: generate intermediate code
- code generation: machine code is generated
linking and loading
process of collecting system program units and linking them to a user program
von neumann bottleneck
- connection speed between a computer’s memory and its processor determines the speed of a computer
- program instructions can be executed faster than the speed of the connection
- Memory and the CPU are separated in the Von Neumann architecture, so the CPU must fetch data for every operation it performs
- limiting factor in the speed of computers
pure interpretation
- no translation
- easier implementation of programs
- slower execution
- often requires more space
hybrid implementation systems
- high-level language program is translated to an intermediate language and allows easy interpretation
- faster than pure interpretation
just in time implementation systems
- initially translate programs to an intermediate language
- compile the intermediate language of the subprograms into machine code when they are called
what do preprocessors do?
processes a program immediately before the program is compiled to expand embedded preprocessor macros (used to specify that code from another file is to be included)
syntax
form or structure of the expressions, statements, and program units
semantics
the meaning of the expressions, statements, and program units
sentence
string of characters over some alphabet
language
set of sentences
lexeme
lowest level syntactic unit of a language
token
category of lexemes
recognizer
reads input strings over the alphabet of the language and decides whether the input strings belong to the language
generator
device that generates sentences of a language
context-free grammar
Language generators, meant to describe the syntax of natural languages
backus-naur form
BNF is equivalent to context-free grammars
Invented by John Backus to describe the syntax of Algol 58
grammar
a finite non-empty set of rules
A start symbol is a special element of the nonterminals of a grammar
Syntactic lists are described using recursion
An abstraction (or nonterminal symbol) can have more than one RHS
ambiguous grammar
A grammar is ambiguous if and only if it generates a sentential form that has two or more distinct parse trees
attribute grammar
a context free grammar with some additions:
- For each grammar symbol x there is a set A(x) of attribute values
- Each rule has a set of functions that define certain attributes of the nonterminals in the rule
- Each rule has a (possibly empty) set of predicates to check for attribute consistency
dynamic semantics
There is no single widely acceptable notation or formalism for describing semantics
operational semantics
Describe the meaning of a program by executing its statements on a machine, either simulated or actual
The change in the state of the machine (memory, registers, etc.) defines the meaning of the statement
denotational semantics
The meaning of language constructs are defined by only the values of the program’s variables