1/62
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What are the different programming domains? (Ch. 1)
Scientific, Business, AI, Systems Programming, Web Software
Examples of Scientific Programming Domains
FORTRAN, ALGOL 60; used primarily for data sets and computations
Examples of Business programming domains
COBOL; used to help make business reports
Examples of AI programming domain
LISP, Prolog, Modern day: Python; uses more linked lists than numbers
Systems programming examples
C, C++, Assembly; needs efficiency, types of languages used for low-level things like compilers
Web software programming domain examples
HTML, JavaScript, PHP; deals with front-end + back-end on the web. HTTP protocols.
What are the criteria to evaluate a programming language?
Readability, writability, reliability, cost (extra: security)
What are two conflicting criteria when evaluating programming languages?
Execution efficiency & portability. It’s hard for programming languages to be very efficient and also work in all kinds of domains.
What are some influences on language design?
Computer/ Von Neumann architecture (CPU,RAM), program design methodologies (ex: object-oriented software development, different types of languages used for different things)
What is an orthogonal language?
A language that does not have many exceptions to it. Rules are straightforward.
For instance, a language that can have an array of essentially any datatype is orthogonal. A language that for some reason cannot have an array of strings but can have an array of any other data type is non-orthogonal.
A programming language that allows an if statement with and without curly brackets is an example of what?
A non-orthogonal language
Java does not have pointers/references like C and C++ does. So the programmer cannot work with memory like it can with the other two languages. However, they won’t have to face any potential memory issues. This is an example of what?
Language design trade-offs
What are the 3 implementation methods with programming languages?
Compilation, Pure Interpretation, Hybrid Implementation Systems. (Think CPH)
How is are languages that are compiled executed?
The compiler translates the high-level code to a low-level program before execution. The new lower-level file is executed quite efficiently.
How are languages that are interpreted exeucted? (pure interpretation)
The interpreter translates the code line-by-line during execution. Execution is slower than compilation.
How are hybrid implementation systems executed?
Source code is translated to bytecode. A Virtual Machine (VM) interprets the code with the help of a Just-in-time (JIT) compiler. The reason this approach exists is because the code becomes executable on a lot more things (Windows, Mac) and the speed is not too slow.
What are 3 things every programming language needs to have to be considered a programming language?
Sequence, selection, iteration.
(Ordering things, like steps; if statements, switch statements; for, while loops, recursion.)
What is it called when a language does not have the 3 requirements to be considered a programming language?
A computer language
(ex: HTML, CSS, JSON)
What primary functionality did Fortran need to have when it came out?
Fortran had to be efficient to compete with assembly language. It’s application was for engineering/scientific purposes.
Why did object-orientation evolve?
To deal with complexity and more abstract concepts.
Evaluate Fortran.
High optimizing compilers, paved the way for most programming languages
Evaluate LISP
Pioneered functional programming
(No variables, only functions and new data (old data cannot be modified), recursion and conditional expressions), still the dominant language for AI)
Evaluate ALGOL 60
Good for publishing algorithms, not widely used in the USA— people saw it as too flexible, so understanding it was more difficult.
Evaluate COBOL
Used by Department of Defense, first macro facility in a high lvl language.
Syntax
the form/structure of the expressions, statements, program units
Semantics
the MEANING of the expressions, statements, program units
BNF (Backus-Naur Form)
a standardized formal notation system (meta syntax) used to precisely define the syntax & grammar rules of programming languages
Non-terminals (BNF)
Anything inside angle brackets, something that needed to be further defined
ex: <expression>, <variable>, <number>
Terminals (BNF)
Anything in quotes. Actual characters/tokens that can appear in the program
ex: “+”, “=“
What does the vertical bar in BNF mean? ( | )
OR
What does the → arrow mean in BNF?
“can be replaced by”, “can be expanded into”
Why is there only one non-terminal on the left side of BNF expressions?
Because programming languages are context-free, not context-sensitive
Four things needed for BNF
1) Terminals
2) Non Terminals
3) Production rewriting rules
4) Start symbol
True or False: When using programming languages, we use context free languages
True
3 primary methods of semantics description
Operational, denotational, axiomatic
Operational Semantics
HOW a program executes step-by-step
Denotational Semantics
WHAT mathematical value/effect a program computes
Axiomatic Semantics
PROPERTIES and correctness of a program
Lexing
The first phase of a compiler/interpreter where it takes character by character source code and breaking it down to a stream of categorized units called tokens
Parsing
Process of converting a stream of raw input data (usually text) into a highly structured format that a computer can easily understand and execute
Variables have 6 attributes to them. What are they?
Name, Address, Value, Type, Lifetime, Scope
What is the address of a variable?
The location in memory, (could be the CPU, RAM, etc.)
What are some things that can affect the name of a variable in a programming language?
Case sensitivity, types of symbols allowed (e.g. letters, numbers, symbols, etc.)
An int 5 is added to a float 2.0. This evaluates to a float 7.0. What kind of type-casting is this?
Implicit Type Casting
(int)5.7 changes the float to an int: 5. What kind of type-casting is this?
Explicit
Which type casting is at a higher risk of data loss?
Explicit type casting
What is the lifetime of a variable?
How long a variable is bound to a memory location.
ex: int x; is declared inside a function. That means x’s lifetime is only when that function is called.
Static scope/lexical scope
Local, non-local, and global variables
What are some possible binding times? (when variables are assigned to a memory cell?)
Compile time, load time, runtime
When is a binding static?
If it first occurs before runtime and remains unchanged throughout program execution
When is binding dynamic?
When the memory location of the variable changes during execution of the program or it first occurs during execution
What is static lifetime for variables?
When a variable is bound to a memory cell before execution and remains bound throughout → global variables
What is stack-dynamic lifetime variables?
When the variable is bound to the stack at runtime
What is explicit heap-dynamic in variable lifetimes?
Explicitly adding something to add to the heap.
ex: new int x;
delete int x;
What are implicit heap-dynamics?
Allocation and deallocation caused by assignment statements
ex: x = 5;
What’s the benefit + disadvantage of implicit heap-dynamic?
It’s flexible; inefficient
Static typing vs dynamic typing
Checking the data type at compile time; Checking data types at runtime
Scalar variables include…
static, stack dynamic, explicit heap dynamic, implicit heap dynamic
Example of Primitive Data Types
int, byte, a pointer, long, short