Download presentation
Presentation is loading. Please wait.
Published byEgbert Henry Modified over 9 years ago
2
ProgrammingLanguages Programming Languages
3
Computational Paradigms
4
Imperative Programming: In most cases the computer in question was the von Neumann model: a single central processing unit that sequentially executes instructions that operate on values stored in memory.In most cases the computer in question was the von Neumann model: a single central processing unit that sequentially executes instructions that operate on values stored in memory. Programming languages began by imitating and abstracting the operations of a computer.Programming languages began by imitating and abstracting the operations of a computer. A programming language that is characterized by these three properties – the sequential execution of instructions, the use of variables representing memory locations, and the use of assignment to change the values of variables – is called an imperative language.A programming language that is characterized by these three properties – the sequential execution of instructions, the use of variables representing memory locations, and the use of assignment to change the values of variables – is called an imperative language.
5
The von Neumann Bottleneck The requirement that computation be described as a sequence of instructions, each operating on a single piece of data, is sometimes referred to as the von Neumann bottleneck.The requirement that computation be described as a sequence of instructions, each operating on a single piece of data, is sometimes referred to as the von Neumann bottleneck. Most programming languages are imperative.Most programming languages are imperative. Since it restricts the ability of a language to indicate parallel computation, and non- deterministic computation, or computation that does not depend on order: asynchronousSince it restricts the ability of a language to indicate parallel computation, and non- deterministic computation, or computation that does not depend on order: asynchronous
6
Functional Programming A functional programming language has as its basic mechanism the evaluation of a function, or the function call.A functional programming language has as its basic mechanism the evaluation of a function, or the function call. The functional paradigm bases the description of computation on the evaluation of functions or the application of functions to known values.The functional paradigm bases the description of computation on the evaluation of functions or the application of functions to known values. The functional paradigm involves no notion of variable or assignment to variables.The functional paradigm involves no notion of variable or assignment to variables. Also, repetitive operations are not expressed by loops but by recursive functions.Also, repetitive operations are not expressed by loops but by recursive functions.
7
Functional Programming: Lisp & Ada (define (gcd u v) (if (= v 0) u (gcd v (modulo u v)))) (define (gcd u v) (if (= v 0) u (gcd v (modulo u v)))) -------------------------------------------------------------------------------------------------------------------------- function gcd (u,v: in integer) return integer is begin if v = 0 then return u; else return gcd(v,u mod v); end if; end gcd;function gcd (u,v: in integer) return integer is begin if v = 0 then return u; else return gcd(v,u mod v); end if; end gcd;
8
Turing Complete A programming language is Turing complete if it has integer values, arithmetic functions on those values, and if it has a mechanism for defining new functions using existing functions, selection, and recursion.A programming language is Turing complete if it has integer values, arithmetic functions on those values, and if it has a mechanism for defining new functions using existing functions, selection, and recursion. The study of recursive function theory in mathematics has established the following property:The study of recursive function theory in mathematics has established the following property:
9
Logic Programming In a logic programming 1anguage, a program consists of a set of statements that describe what is true about a desired result.In a logic programming 1anguage, a program consists of a set of statements that describe what is true about a desired result. This language paradigm is based on symbolic logic.This language paradigm is based on symbolic logic. A pure logic programming language has no need for control abstractions such as loops or selection.A pure logic programming language has no need for control abstractions such as loops or selection. For this reason, logic programming is also called declarative programming, since properties are declared, but no execution sequence is specified. logic programming languages are referred to as very-high-level languages.For this reason, logic programming is also called declarative programming, since properties are declared, but no execution sequence is specified. logic programming languages are referred to as very-high-level languages.
10
Prolog gcd(U,V,U) : – V=0. gcd(U,V,X) : – V > 0, Y is U mod V, gcd(V,Y,X). The gcd of u and v is u if v = 0.The gcd of u and v is u if v = 0. The gcd of u and v is the same as the gcd of v and u mod v if v is > 0.The gcd of u and v is the same as the gcd of v and u mod v if v is > 0.
11
Object-Oriented Programming It is based on the notion of an object, which can be loosely described as a collection of memory locations together with all the operations that can change the values of these memory locations.It is based on the notion of an object, which can be loosely described as a collection of memory locations together with all the operations that can change the values of these memory locations. Object-oriented programming, not only is a language paradigm, but also is a methodology for software program design.Object-oriented programming, not only is a language paradigm, but also is a methodology for software program design. It represents computation as the interaction among, or communication between, a group of objects, each of which behaves like its own computer, with its own memory and its own operations.It represents computation as the interaction among, or communication between, a group of objects, each of which behaves like its own computer, with its own memory and its own operations.
12
Object Classes Classes are defined using declarations, much as structured types are declared in a language like CClasses are defined using declarations, much as structured types are declared in a language like C In many object-oriented languages, objects are grouped into classes that represent all the objects with the same properties.In many object-oriented languages, objects are grouped into classes that represent all the objects with the same properties. Objects are then created as particular examples, or instances, of a class.Objects are then created as particular examples, or instances, of a class.
13
Example in Java public class IntWithGcd; { public IntWithGcd(int val) { value = val;} public int intValue() { return value;} public int gcd ( int v) { int z = value; int y = v; while (y != 0) { int t = x; y = z % y; z = t; } return z; } private int value; }
14
Example in Java This class can be used by defining an object of the class as follows: IntWithGcd x;This class can be used by defining an object of the class as follows: IntWithGcd x; Then we can ask x to tell us its value by calling the value procedure, as for example, in int y = x.gcd(18);Then we can ask x to tell us its value by calling the value procedure, as for example, in int y = x.gcd(18); we must create, or instantiate, the object with the following statement: x = new IntWithGcd(8);we must create, or instantiate, the object with the following statement: x = new IntWithGcd(8);
15
Event-Driven Visual Programming All the paradigms we’ve examined are based on a fundamental model of computation in which the program design predetermines what will occur when the program is run.All the paradigms we’ve examined are based on a fundamental model of computation in which the program design predetermines what will occur when the program is run. They are written to run reasonably to any particular sequence of events that may occur once execution begins,They are written to run reasonably to any particular sequence of events that may occur once execution begins, Event-driven programs do not predict the control sequence that will occur;Event-driven programs do not predict the control sequence that will occur; In this model, the input data govern the particular sequence of control that is actually carried out by the program.In this model, the input data govern the particular sequence of control that is actually carried out by the program.
16
Event-Driven Visual Programming Execution of an event-driven program does not typically terminate; such a program is designed to run for an arbitrary period of time, often indefinitely.Execution of an event-driven program does not typically terminate; such a program is designed to run for an arbitrary period of time, often indefinitely. The most widespread example of an event-driven program is the GUI mouse- and, windows-driven user interface.The most widespread example of an event-driven program is the GUI mouse- and, windows-driven user interface. Event-driven programs also drive web-based applications.Event-driven programs also drive web-based applications.
17
Event-Driven Visual Programming To provide effective support for event-driven programming, some languages have developed some basic terminology and principles of design.To provide effective support for event-driven programming, some languages have developed some basic terminology and principles of design. Most recently, these principles have appeared in Java, though other languages like Visual Basic also support event-driven programming.Most recently, these principles have appeared in Java, though other languages like Visual Basic also support event-driven programming.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.