Computer Languages and Representations Flashcards
What is a factor of the Software crisis and when did the Software crisis begin?
Began - 1960s
High cost of producing software - software costs have been rising as hardware costs have been falling
How are Programs represented and Computation implemented in:
- Functional Programming
- Logic Programming
- Finite State Machines
- Programs are represented by expressions. Computation is represented by reduction
- Programs are represented by clauses
Computation is represented by proof - Programs are represented by state machines
Computation is represented by transitions
What are the foundations in Functional and Logic programming?
Functional Programming - lambda calculus
Logic Programming - first-order logic
Define a Function
A function transforms information recieved by inputs to information transmitted by output.
What are arguments and results in functions?
Argument = Inputs
Results = Outputs
What is a must for an equation to apply?
Argument must match the pattern for an equation
(Any argument matches a variable pattern)
What is a Pattern?
A pattern may describe the structure of the argument and name its components
What is a Guard?
A guard is a Boolean expression that must be true for the equation to apply.
(Guards often work with patterns)
Define “otherwise”
A special final guard that is always true.
How are functions written in programming?
The function f to an argument x is written as f x.
What is a Type?
Set of values with the same usage and behaviour.
(All of the values in one of these sets are the same kind of thing such as an integer)
What is a Type System?
The fundamental purpose of a type system is to prevent errors during the execution of the programs, by ensuring types match correctly.
What is Type Checking?
Ensures types are used consistently, and that these errors are avoided.
Define Static Type Checking
Happens before program execution
Define Dynamic Type Checking
Happens during program execution
What is a negative of Local Defintions?
Having all function at the top level of a script can lead to name space pollution - clashes caused by reuse of the same name.
What is a Where Definition?
A where definition allows one to name a value, and to use it in an expression.
What is a Let Definition?
A let definition allows one to name a value, and to use it in an expression.
What are the steps for Polya’s heuristic strategies?
- Understand the problem
- Devise a plan
- Carry out the plan
- Look back and reflect
Explain Understanding the problem in Polya’s heuristic strategies.
Involves careful study. May seem obvious, but failure to understand the problem often explains a failure to solve it.
Explain Devising a plan in Polya’s heuristic strategies.
Involves identifying calclulations, computations or constructions that may be performed in order to obtain the solution
What are 3 key questions when Devising a plan?
- Did you use all the data?
- Did you use the whole condition?
- Could you use a related problem, solved before?
Explain Carrying out the plan in Polya’s heuristic strategies.
Involves performing the steps in sequence to give the solution.
What are 2 key questions when Carrying out the plan?
- Can you see each step is correct?
- Can you prove each step is correct?
Explain Reflecting in Polya’s heuristic strategies.
Taking time to consider what worked and what didn’t. The insights gained may make it easier to find solutions to future problems
What are 3 key questions when Reflecting?
- Can you check the result?
- Can you check the argument?
- Can you use the result/method for some other problem?
What is a design pattern?
It captures the idea of a good solution to a common design problem
They can make novices look like experts.
What is the Generate-and-select design pattern?
Generator construct a large number of values that might be solutions to a problem.
Selector filters out those values that are solutions to the problem.
What is the productivity paradox?
You can see computer age everywhere but in the productivity statistics
What are the three explanations of the productivity paradox?
- Uneven/concentrated gains
- Implementation lags
- Mismeasurement
Explain Uneven/concentrated gains in relation to the productivity paradox.
The gains are in few productive firms and sectors with limited weight in the overall economy.
Explain Implementation lags in relation to the productivity paradox.
It takes considerable time for a new technologies to achieve critical mass, or for necessary complementary ones to appear.
Explain Mismeasurements in relation to the productivity paradox.
Adopting new technologies can lead workers to move on from more productive adopting sectors to less productive ones, and so to negligible aggregate productivity growth.
How do Artificial Neural Networks (ANNs) work behind the scenes?
- The core ANN is trained on text from the Internet to respond to a prompt with a list of most probable next words after the prompt
- The core ANN is tweaked by scoring its responses to sample queries. A second NN is trained on these scores to predict the most likely one to be assigned to a prompt.
- The second ANN is used in reinforcement learning to adjust the weights iin the core ANN so that its outputs are even most likely to satisfy humans
- Sometimes, data from user responses to LLM responses is fed back to fine-tune for still better results
What are the concerns when using the large language models?
- Copyright
- Education
- Code quality
- Code security
- Not an expert
What is the Education concern when using large language models?
Good solutions to many assignments can be completed directly, reducing their challenge and worth
What is the Code quality concern when using large language models?
No guarantee of code quality when using a large language model, and a code review will need to be conducted before code is deployed.
What is the Code security concern when using large language models?
No guarantee of code security when using a large language, and a security audit will need to be conducted before code is deployed
What is the information concern when using large lanuage models?
It is not an expert - doesn’t know and will confabulate if necessary, mixing high-quality text with low quality rubbish
Define List Processing
Is naturally recursive. The result of a computation on a list is often most easily described in terms of its head and a recursive computation on its tail, until a base case list is reached
Define the Head of a list
First item of list
Define the Tail of a list
The rest of the items (not including the first)
What is a List Comprehension?
Items generated from one list are transformed or tested to give items of another
What is a Conditional Expression?
A conditional expression evaluates to one expression or the other, depending on the value of a Boolean expression
What is a Case Expression?
A case expression evaluates to the expression for a given case
- A case expression may have a base case
What is nub used for in Haskell?
Removes duplicate elements from a list.
- Only keeps the first occurrence of each element, preserving the order.
What is Lit used for in Haskell?
Refers to literals which represent basic constant values like numbers, characters or strings
Why is Code Copying bad?
Error-prone
- Errors must be fixed in every copy
Inefficient
- Space must be allocated for each copy
What are the 5 types of Data Objects?
- Numbers
- Atoms
- Variables
- Compound terms
- Lists
Define a Number
Either an integer or floating point
Define an Atom
A constant that does not have a numerical value. It begins with a lowercase letter, or its quoted