Unit 1 - Programming Paradigms, Functional Programming in Lisp, Haskell Flashcards
Reasons for studying programming language concepts
- Increased capacity to express programming ideas
- Increased ability to learn new programming languages
- Improved background for choosing a programming language
- Increased ability to design good quality new languages
- Overall advancement of computing and an improvement in the quality of software
Desirable Programming Language attributes
- Expressive
- Concise
- Safe
- Easy to read
- Executes efficiently
- Supporting reuse of code via abstraction
- Easy to learn
- Good standard libraries
Define Programming language attribute: Expressive
Whatever data and actions we can imagine the computer doing, we can code them in the language somehow.
Define Programming language attribute: Concise
In order to achieve the desired functionality, there is no need to write lots of boring set-up code and datatypes can be defined in a straightforward manner. Also, one should be able to avoid cutting-and-pasting large portions of code
Define Programming language attribute: Safe
Ideally, most programming errors lead to invalid programs so that they can be discovered at compile time. Otherwise, a valid but incorrect program could be executed, causing damage.
Define Programming language attribute: Easy to read
Most programs are developed jointly by a team. Even more often someone else has to maintain it than the one who wrote it.
Define Programming language attribute: Executes efficiently
If at all there is an efficient solution to our problem, then writing it in our language should give us an efficient program.
(Some problems just cannot be solved quickly, eg machine translation from English to French or finding a good move in chess.)
Define Programming language attribute: Supporting reuse of code via abstraction
When two data structures or activities are very similar, we should not need to write two descriptions for them that are mostly identical. We should write one that can be applied to both cases (as well as to other similar cases that are likely to come up in the future).
Define Programming language attribute: Easy to learn
One should be expected to learn a PL competently in not more than a few months
Define Programming language attribute: Good standard libraries
Every PL has a set of standard libraries that must be present during execution. A programmer has to be familiar with them, or at least a part of them to make best use of the language. The libraries extend the facilities provided by the PL itself and their quality and quantity can have major influence on all the previously discussed properties.
Examples of Interpreted PLs
Python
Lisp (Used to be. Modern Lisp is compiled)
Compiled and Interpreted: Java
Note: Most do a bit of both and are not that consistent as they have different distros that operate differently. Equally a lot of University supplied notes on this are very out of date.
Examples of Compiled PLs
C, Ada, Haskell
Compiled and Interpreted: Java
Note: Most do a bit of both and are not that consistent as they have different distros that operate differently. Equally a lot of University supplied notes on this are very out of date.
Define an Imperative PL
The most common PLs portray a machine in which there is one or more active entities (usually called threads) that manipulate data kept in a data store.
OO languages (such as Java, C++ and Python) group
instructions with the definitions of the data structures that they operate on.
Define a Functional PL
An alternative view of an abstract computer is that its program and its data are one and the same thing. To compute means to transform the program (ie data) according to some rules.
Define a logical PL
These languages portray an even more abstract model of a computer than functional PLs. Here, a computer is a semi-intelligent agent and a program is a bunch of knowledge represented in a simple form of logic
What does a compiler do?
Is it more or less efficient than interpretation?
The program is translated into an equivalent program in native machine code, which can be executed directly by the CPU.
This is a more efficient option, typically 10× faster than interpretation.
Compilers are hard to port from one type of computer to another
Define an interpreter
written in a lower-level language that reads the program text and simulates what the abstract machine is supposed to do.
Define a Procedural PL
In procedural languages (such as C and Ada), the instructions and data structure definitions are associated with each other much more loosely.
Give examples of ideal PL criteria that contradict each other
E.g. conciseness, expressiveness imply that the language is quite abstract and advanced and therefore not easy to learn and quite likely have problems with efficiency. (Many would name Haskell, Lisp and Prolog as examples here.)
Name 3 Programming Paradigms
Imperative PLs
Functional PLs
Logical PLs
What is JIT
Just in time compilation
compilation during execution of a program rather than before execution.