CS代考计算机代写 Java data structure flex prolog Fortran c++ c# jvm ada compiler PowerPoint Presentation
PowerPoint Presentation
© M. Winter
COSC 2P05 – Programming languages
2.*
First attempt to design a language that could be used for a broad spectrum of application areas
Developed by IBM in 1963
PL/I includes the best parts of
Algol 60 (block structure and recursion)
Fortran IV (separate compilation with communication through global data)
COBOL (data structures, input/output, report generating facilities)
Huge language with a lot of features; first in having
Creating concurrently executing subprograms
Exception handling; 23 different types of exceptions or run-time errors
Efficient linking for nonrecursive subprograms
Pointers were included as a data type
Cross-sections of arrays could be referenced
PL/I
© M. Winter
COSC 2P05 – Programming languages
2.*
/* PL/I PROGRAM EXAMPLE
INPUT: AN INTEGER, LISTLEN, WHERE LISTLEN IS LESS THAN
100, FOLLOWED BY LISTLEN-INTEGER VALUES
OUTPUT: THE NUMBER OF INPUT VALUES THAT ARE GREATER THAN
THE AVERAGE OF ALL INPUT VALUES */
PLIEX: PROCEDURE OPTIONS (MAIN);
DECLARE INTLIST (1:99) FIXED.
DECLARE (LISTLEN, COUNTER, SUM, AVERAGE, RESULT) FIXED;
SUM = 0;
RESULT = 0;
GET LIST (LISTLEN);
IF (LISTLEN > 0) & (LISTLEN < 100) THEN
DO;
/* READ INPUT DATA INTO AN ARRAY AND COMPUTE THE SUM */
DO COUNTER = 1 TO LISTLEN;
GET LIST (INTLIST (COUNTER));
SUM = SUM + INTLIST (COUNTER);
END;
A PL/I Program
© M. Winter
COSC 2P05 – Programming languages
2.*
/* COMPUTE THE AVERAGE */
AVERAGE = SUM / LISTLEN;
/* COUNT THE NUMBER OF VALUES THAT ARE > AVERAGE */
DO COUNTER = 1 TO LISTLEN;
IF INTLIST (COUNTER) > AVERAGE THEN
RESULT = RESULT + 1;
END;
/* PRINT RESULT */
PUT SKIP LIST (‘THE NUMBER OF VALUES > AVERAGE IS:’);
PUT LIST (RESULT);
END;
ELSE
PUT SKIP LIST (‘ERROR-INPUT LIST LENGTH IS ILLEGAL’);
END PLIEX;
© M. Winter
COSC 2P05 – Programming languages
2.*
Both languages are not based on any previous language
Common: Dynamic typing and storage allocation
APL
Designed around 1960 at IBM
Published in the book “A Programming Language” in 1962
Large number of powerful operators
Hard to maintain
SNOBOL
Designed in the early 1960s for text processing
Powerful operations for string pattern matching
APL and SNOBOL
© M. Winter
COSC 2P05 – Programming languages
2.*
SIMULA I was developed between 1962 and 1964 in Norway
Designed for simulations
Later extended to become a general purpose language
SIMULA 67 presented in 1967
Extends Algol 60
Introduces coroutines
Introduces the class construct
SIMULA 67
© M. Winter
COSC 2P05 – Programming languages
2.*
Developed at Bell Laboratories in 1972
Ancestors: CPL, BCPL, B, and Algol 68
Designed as a language to implement UNIX
Fist official standard in 1989 (ANSI C); next in 1999 (C99)
Lack of complete type checking
C
© M. Winter
COSC 2P05 – Programming languages
2.*
/* C Example Program
Input: An integer, listlen, where listlen is less than
100, followed by listlen-integer values
Output: The number of input values that are greater than
the average of all input values */
int main (){
int intlist[99], listlen, counter, sum, average, result;
sum = 0;
result = 0;
scanf(“%d”, &listlen);
if ((listlen > 0) && (listlen < 100)) {
/* Read input into an array and compute the sum */
for (counter = 0; counter < listlen; counter++) {
scanf("%d", &intlist[counter]);
sum += intlist[counter];
}
/* Compute the average */
average = sum / listlen;
A C Program
© M. Winter
COSC 2P05 – Programming languages
2.*
/* Count the input values that are > average */
for (counter = 0; counter < listlen; counter++)
if (intlist[counter] > average) result++;
/* Print result */
printf(“Number of values > average is:%d
”, result);
}
else
printf(“Error-input list length is not legal
”);
}
© M. Winter
COSC 2P05 – Programming languages
2.*
Object-oriented version of C
Goals:
Add classes and inheritance
No performance penalty
Development steps
C with Classes (1983)
Extension with virtual methods (1984), first version called C++
First implementation in 1985 (Cfront)
Multiple inheritance, abstract classes (1989, C++ Release 2.0)
Templates, parametrized types, exception handling (1990, C++ Release 3.0)
Current C++ standardized in 1998, described in ISO
C++
© M. Winter
COSC 2P05 – Programming languages
2.*
Features
Supports procedural and object-orientated programming
Multiple inheritance
Operator overloading
Virtual methods
Class and method templates
Exception handling
Very popular language
Very large and complex
Inherits the insecurities of C, less safe than Ada or Java
C++
© M. Winter
COSC 2P05 – Programming languages
2.*
Language for logic programming
Uses predicate calculus to formulate programs
Nonprocedural
Describes the form and/or characteristics of the result rather than how to compute it
Developed in 1972 in Marsaille
Prolog program consists of two kinds of statements: facts and rules
mother(joanne, jake).
father(vern, joanne).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
Queries are resolved using resolution (prove method)
Prolog
© M. Winter
COSC 2P05 – Programming languages
2.*
Developed by the DoD in 1980
More than 450 different programming languages were use in DoD projects
None was suitable for embedded system design
Design competition from 1975 onwards
First complete language specification was published in ACM SIGPLAN for discussion
Revised version became Ada Language Reference Manual (1980)
Revised again in 1982
In 1983 the American National Standards Institute standardized Ada; design frozen for at least 5 years.
Ada
© M. Winter
COSC 2P05 – Programming languages
2.*
Most important aspects of Ada
Anybody could participate in the design competition
Includes most concepts of software engineering and language design of the late 1970s
First compiler was available in 1985
Very large and highly complex.
Ada 95 and Ada 2005
Inheritance
Polymorphism
Improved sharing of data between concurrent processes
DoD stopped requiring Ada in military software
Ada
© M. Winter
COSC 2P05 – Programming languages
2.*
— Ada Example Program
— Input: An integer, List_Len, where List_Len is less
— than 100, followed by List_Len-integer values
— Output: The number of input values that are greater
— than the average of all input values
with Ada.Text_IO, Ada.Integer.Text_IO;
use Ada.Text_IO, Ada.Integer.Text_IO;
procedure Ada_Ex is
type Int_List_Type is array (1..99) of Integer;
Int_List : Int_List_Type;
List_Len, Sum, Average, Result : Integer;
begin
Result:= 0;
Sum := 0;
Get (List_Len);
if (List_Len > 0) and (List_Len < 100) then
-- Read input data into an array and compute the sum
An Ada Program
© M. Winter
COSC 2P05 – Programming languages
2.*
for Counter := 1 .. List_Len loop
if Int_List(Counter) > Average then
Result:= Result+ 1;
end if;
end loop;
— Print result
Put (“The number of values > average is:”);
Put (Result);
New_Line;
else
Put_Line (“Error-input list length is not legal”);
end if;
end Ada_Ex;
© M. Winter
COSC 2P05 – Programming languages
2.*
First object-oriented programming language
Originated in the PhD thesis of Alan Kay in the late 1960s as part of the Dynabook idea
Kay developed an “Interim” Dynabook, consisting of Xerox Alto hardware and Smalltalk-72 at Xerox.
In 1980 a better Dynabook using Smalltalk-80 was developed
Features
Everything in Smalltalk is an object
Computing is done by sending messages to an object by invoking one of its methods
A reply to a message is an object
Classes are object abstractions that can create objects
Smalltalk used a graphical user interface (windowed)
Smalltalk
© M. Winter
COSC 2P05 – Programming languages
2.*
“Smalltalk Example Program”
“The following is a class definition, instantiations of which can draw equilateral polygons of any number of sides”
class name Polygon
superclass Object
instance variable names ourPen
numSides
sideLength
“Class methods“
“Create an instance”
new
^ super new getPen
“Get a pen for drawing polygons”
getPen
ourPen <- Pen new defaultNib: 2
A Smalltalk Program
© M. Winter
COSC 2P05 – Programming languages
2.*
"Instance methods"
"Draw a polygon"
draw
numSides timesRepeat: [ourPen go: sideLength; turn: 360 // numSides]
"Set length of sides"
length: len
sideLength <- len
"Set number of sides"
sides: num
numSides <- num
© M. Winter
COSC 2P05 – Programming languages
2.*
Java is based on C++
Similar power and flexibility
Smaller, simpler, and safer
Developed by Sun Microsystems in 1990 as a language for embedded consumer electronic devices
Primary goal: Reliability
Become a useful tool for web programming starting in 1993
JVM is not part of the language design
Java
© M. Winter
COSC 2P05 – Programming languages
2.*
Based on C++ and Java
Adds ideas from Delphi and Visual BASIC
Brings back a lot of features from C++ that were removed in Java, e.g.,
enum types
Operator overloading
Much safer than C++
C#