Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simula Programming Language Lenar Uri T. Barcelona.

Similar presentations


Presentation on theme: "Simula Programming Language Lenar Uri T. Barcelona."— Presentation transcript:

1 Simula Programming Language Lenar Uri T. Barcelona

2 It all started with a need… Kristen Nygaard realized, through his work in the Norwegian Defense Research Establishment, that there is a need for simulation tools Kristen Nygaard realized, through his work in the Norwegian Defense Research Establishment, that there is a need for simulation tools

3 It all started with a need… Nygaard left NDRE and put up NCC (Norwegian Computing Center) where, similar to his previous job, he realized that there is a need for simulation tools Nygaard left NDRE and put up NCC (Norwegian Computing Center) where, similar to his previous job, he realized that there is a need for simulation tools

4 History of Simula Summer 1961- Fall 1962 Summer 1961- Fall 1962 The concept of a mathematical discrete event network and programming language reasoning for Simula I were developed by Nygaard and Dahl The concept of a mathematical discrete event network and programming language reasoning for Simula I were developed by Nygaard and Dahl Fall 1962- September 1963 Fall 1962- September 1963 It was decided that Simula I would be implemented as a simulation procedure package along with a preprocessor to Algol 60

5 History of Simula September 1963 - March 1964 September 1963 - March 1964 A new storage management scheme A new storage management scheme Simula I would be implemented through a modification and extension of Univac's Algol 60 compiler Simula I would be implemented through a modification and extension of Univac's Algol 60 compiler March 1964- December 1964 March 1964- December 1964 The first prototype was completed in December Minor language modifications were made Extensions based on implementation experience and programming test cases were completed

6 History of Simula Fall of 1965 Fall of 1965 The Technical University of Norway wanted to implement a new Algol 60 compiler on the Univac 1100 series The Technical University of Norway wanted to implement a new Algol 60 compiler on the Univac 1100 series Nygaard and Dahl determined that attribute accessing and common properties of processes were the most significant problems in Simula I Nygaard and Dahl determined that attribute accessing and common properties of processes were the most significant problems in Simula I December 1966 December 1966 Prefixing Today, prefixing is known as inheritance Class Concept Prefixing can be extended to include multiple prefixing thus establishing hierarchies of process classes This led to the idea of objects

7 Features of Simula Classes Classes Objects Objects instance variables instance variables methods methods Inheritance Inheritance Sub-typing Sub-typing “Inner” “Inner” supports method combination supports method combination "Virtual" methods "Virtual" methods methods that can be redefined in derived classes Inspect/QUA Inspect/QUA run-time class (type) tests Encapsulation Encapsulation "Protected" which means that they are accessible for subclasses "Hidden" in which case that are not accessible to subclasses either

8 Extensions/Modifications of Algol 60 Added: Added: Class concepts and reference-variables (pointers to objects) Class concepts and reference-variables (pointers to objects) Pass-by-reference Pass-by-reference Char, Text, and I/O Char, Text, and I/O Co-routines Co-routines Removed: Removed: Changed default parameter passing mechanism from call-by-name to pass-by-value Changed default parameter passing mechanism from call-by-name to pass-by-value Pass-by-result Pass-by-result Some variable initialization requirements Some variable initialization requirements String type (in favor of "text" type) String type (in favor of "text" type)

9 Problems with Simula Language features: Language features: Limited file access facilities Limited file access facilities Missing data types (records, sets) Missing data types (records, sets) No real time support No real time support No GUI support No GUI support Long executable files for short programs Long executable files for short programs OOP features: OOP features: No multiple inheritance No interfaces Simulation: Simulation: No automatic collection of statistics No report generator No specialized facilities

10 Implicit Conversion Implicit conversion is performed, where necessary, each time a term- operator-term triple is evaluated Implicit conversion is performed, where necessary, each time a term- operator-term triple is evaluated General Rules General Rules 1. If the operator is integer divide, //, both terms must be integer or short integer; use of reals or long reals constitutes a runtime error

11 Implicit Conversion 2. All short integer values are converted to integer; this can never cause a conversion error 3. If the operator is real divide, /, both terms are converted to real or long real, in accordance with (4) 4. Where the terms are of different types and at least one is real or long real conversion is performed; if one term is long real the other is converted to long real otherwise the non-real term is converted to real

12 Operators in Simula OperatorExample Exponentiation**2**5 = 32 Multiplication*2*5 = 10 Division of real numbers /2/5 =.4 Division of integers //2/5 = 0 Addition+2+5 = 7 Subtraction-2-5 = -3

13 Relational Operators in Simula SymbolAlternativeMeaning =eqis equal to <>neis not equal to >gtis greater than <ltis less than >=ge is greater than or equal to <=le is less than or equal to

14 Simple Types in Simula KeywordInitial ValueDescription integer0 Any integer value, positive or negative. short integ er 0 real0.0 Any decimal value, positive or negative. long0.0 characterISO NULLAny single character. BooleanFalse Can only hold one of two values, True or False. text NoText, equivalent to "" Any string.

15 Syntax Rules - Blocks begin comment Our first SIMULA program; integer Count; count := 3; OutInt(Count,4); OutImage end

16 Syntax Rules - Declarations procedure PrintTimes(T1, count); text T1; integer count; begin integer i; i := 0; while i < count do begin OutText(T1); OutImage; end; end;

17 Syntax Rules - Declarations class HelloWorld; begin text outPut; outPut :- "Hello World"; procedure sayHello; begin OutText(outPut); end; end;

18 Syntax Rules - Recursion begin procedure factorial(m); integer m; begin if m > 0 then begin factorial := m * factorial(m-1); end; else factorial := 1; end; OutInt(factorial(5),4); end

19 Syntax Rules – if then else integer count, countAgain; count := 2; countAgain := 3; if count = 2 then begin if countAgain = 3 then OutText("I will be printed"); end;

20 Syntax Rules - while integer count; count := 0; while count < 10 do begin OutInt(count, 4); OutImage; count := count + 1; end;


Download ppt "Simula Programming Language Lenar Uri T. Barcelona."

Similar presentations


Ads by Google