Types of programming languages Flashcards

(31 cards)

1
Q

what is a programming paradigm?

A

It is a style of programming
Some languages only support one type of paradigm (eg. Haskell, small Basic) but some support more than one (eg. Python, Java, C#)

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

What are the 4 programming paradigms? (and give an example)

A
  • procedural programming - eg. Python, Basic, C#
  • object oriented - eg. Python, Java, VisualBasic.NET
  • declarative programming - eg. SQL, Prolog
  • Functional programming - eg. Haskell, Javascript, Logo
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is procedural programming?

A
  • consists of a series of instructions that tell the computer what to do with the inputs in what order to solve the problem
  • languages using this paradigm have built in data types (eg. integer, floating point numbers etc) + data structures such as arrays + records
  • programmers can also define their own abstract data types eg. queue, stack, tree, hash table, etc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is structured programming?

A
  • a type of procedural programming
  • uses sequence, selection, iteration + recursion instead of goto techniques
  • uses modular techniques - splits large programs into manageable chuncks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is declarative programming?

A
  • you write statements that describe the problem to be solved
  • language implementation decided the best way to solve the problem
  • doesnt execute in the same order as the statements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is logic programming?

A
  • a form of declarative programming
  • a paradigm that expresses the logic of a computation without expressing its control flow
  • programs consist of logical statements
  • eg. prolog
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is functional programming?

A
  • functions are used as the building blocks of a program
  • statements are written as a series of functions which accept input data as arguments + return an output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

when might a declarative programming language be used?

A
  • in expert systems (eg. medecine)
  • embodies fasts and rules about a particular field of knowledge - medical diagnosis, oil exploration, tax regs
  • natural language processing (normal human language) - text to speech, spell checking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is backtracking?

A
  • usually done during recursion
  • if a dead end is found go back to the previous choice that was made
  • this is repeated until the thing needed is found/all possible paths are exhausted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is an abstract data type?

A

queue, stack, tree, graph, hash table, etc.

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

what is object oriented programming?

A
  • more abstract thinking - think about the objects that will complete the tasks, not the data structures + algorithms
  • makes it possible to abstract details of implementation away from the programmer
  • makes reusable code
  • programs are easy to maintain
  • programs are made of objects with attributes (data about the object) + methods (operations on the data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a class?

A

the description of what the data looks like (the state) and what the data can do (the behavior) - kinda like a blueprint for the object- defines attributes + methods

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

what is an object?

A

a specific instance created based on the blueprint (class) that has its own unique data values

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

what is instantiation?

A

the process of creating an object of a class - memory is allocated for its attributes + initial values are set

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

what is a constructor?

A

a method that creates an instance of a class. in pseudocode:
instance = new class(parameters)

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

what does it mean if an attribute is private?

A

users cannot directly access or change them - they can only be changed through methods (functions or procedures)

17
Q

what is recursion?

A
  • it is a programming construct where a subroutine call itself during execution until the stopping condition is met
  • produces the same results as iteration but using fewer lines of code
  • can be inefficient with memory and cause a stack overflow (the stack runs out of memory)
  • difficult to trace, esp with more function calls
18
Q

what are local variables and why are they good?

A
  • variables that can be accessed only within the block of code in which they were defined
  • eg. if defined in a subroutine can only be accessed in the subroutine
  • good because it makes sure subroutines are self contained - variables can’t be affected by code elsewhere
19
Q

what is a global variable and why are they good?

A
  • variables that can be accessed across the whole program
  • any variables declared in the main body of the program are global variables
  • useful if a value needs to be used in multiple parts of the program
  • not great because they can be accidentally overwritten
  • also use more memory than local variables because they are terminated at the end of the program rather than the end of the subroutine
20
Q

what is encapsulation?

A

when attributes and methods are bundled together under a single unit - eg. a class
good because it protects attributes being accessed directly
code for different classes can be produced independently of each other

21
Q

what is a setter?

A

a method that sets the value of a particular attribute

22
Q

what is a getter?

A

a method that retrieves the value of a given attribute

23
Q

what is the difference between a function and a procedure?

A
  • function: returns a value
  • procedure: doesnt return a value, just completes a task
24
Q

what is inheritance?

A
  • a relationship among classes where a subclass shares all the attributes + methods from a parent class/superclass
  • good because it saves time redefining shared attributes + methods
25
what does a class diagram look like?
there are boxes representing the classes, with their attributes and methods and arrows pointing from subclasses to superclasses
26
what is polymorphism?
a programming language's ability to process objects differently depending om their class - methods are redefined this can lead to the same method producing different outputs depending on the object involved
27
what is overriding?
redefining a method in a subclass + altering code so that it functions differently + produces a different output
28
what is overloading?
passing different parameters into a method to produce a different output
29
what are the advantages of object oriented programming?
- forces an extensive planning phase - better designs with fewer weaknesses - encapsulation means that different object's code can remain independent of each other + be tested separately - once an object is created you don't need to know how its methods work to use them - new objects can be easily created with small differences to existing ones - reuseable - defined and tested objects can be used in different programs - good framework for code libraries - lots of software components that can be easily adapted by a programmer - easier to maintain than a procedural language program because of modular structure
30
what do mnemonics in assembly language represent?
they represent operation codes + addresses
31