Unit 1 - Programming Paradigms, Functional Programming in Lisp, Haskell Flashcards

1
Q

Reasons for studying programming language concepts

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Desirable Programming Language attributes

A
  • Expressive
  • Concise
  • Safe
  • Easy to read
  • Executes efficiently
  • Supporting reuse of code via abstraction
  • Easy to learn
  • Good standard libraries
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Programming language attribute: Expressive

A

Whatever data and actions we can imagine the computer doing, we can code them in the language somehow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Programming language attribute: Concise

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Programming language attribute: Safe

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define Programming language attribute: Easy to read

A

Most programs are developed jointly by a team. Even more often someone else has to maintain it than the one who wrote it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define Programming language attribute: Executes efficiently

A

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.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define Programming language attribute: Supporting reuse of code via abstraction

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define Programming language attribute: Easy to learn

A

One should be expected to learn a PL competently in not more than a few months

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define Programming language attribute: Good standard libraries

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Examples of Interpreted PLs

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Examples of Compiled PLs

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define an Imperative PL

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

OO languages (such as Java, C++ and Python) group

A

instructions with the definitions of the data structures that they operate on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Define a Functional PL

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define a logical PL

A

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

15
Q

What does a compiler do?

Is it more or less efficient than interpretation?

A

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

16
Q

Define an interpreter

A

written in a lower-level language that reads the program text and simulates what the abstract machine is supposed to do.

17
Q

Define a Procedural PL

A

In procedural languages (such as C and Ada), the instructions and data structure definitions are associated with each other much more loosely.

18
Q

Give examples of ideal PL criteria that contradict each other

A

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.)

19
Q

Name 3 Programming Paradigms

A

Imperative PLs
Functional PLs
Logical PLs

20
Q

What is JIT

A

Just in time compilation

compilation during execution of a program rather than before execution.