CS 342 Lecture -*- Outline -*- * Ada Designed under contract for the US DoD in late 1970s ** Motivation Costs of producing software seemed to be (at least) quadratic in program's length. (Simple reason: project of N people has O(N**2) communications) Control of complexity through modularization: Parnas (1971): use modules to hide design decisions *information hiding* Abstract data type (from Simula, late 1960s) -common decisions to hide involve data structures -module encapsulates knowledge about data structure + algorithms used to manipulate it abstract type: objects + operations *stack example *draw picture relating implentation to abstraction Languages such as CLU, Mesa, Euclid, Modula ** History DoD spending $3 billion anually for software -most on embeded systems (part of a missle, etc.) -lot of money spent because software was not portable, not reusable because using over 400 languages and dialects (some very dated). Wanted one language + data abstraction 1975 Specified the language in detail (using comments from each service) 1977 Ironman requirements competitive design effort, originally 16 languages four finalists: red=Softech, yellow=SRI, red=Intermetrics, green=Honeywell Bull 1978 judged by about 100 evaluations teams -red and green given more money for another round 1979 committee chose Green -designers led by Jean Ichbiah language named Ada after "first programmer" (for Ch. Babbage) Augusta Ada, Countess of Lovelace (daughter of poet Byron) 1980 revision to Ada 1983 ANSI standard 1984 military makes Ada mandatory for all mission-critical software ** IRONMAN requirements (go fast!) (July 1977, SIGPLAN) use this as an overview and point out how specific requirements were *** General (goals) -no unnecessary generality applications to support: real-time control, self diagnostics, I/O to nonstandard devices parallel processing, numeric computation, file processing -aid the design of reliable programs no error prone features, maximize detection of errors -promote ease of program maintenance emphasize readability, encourage documentation discourages defaults -efficiency (of programs at run-time) -simplicity no unnecessary complexity, few special cases -implementability already understood features, all restrictions enforcable by translator (not true of Ada) -machine (representation) independence -formal definition (where it helps) *** Syntax (point out how specific these are) -64 character subset of ASCII for portability -no syntaactic extensions or new precedence rules *law of least astonishment* (constructs should have semantics that would produce the least astonishment) -use reserved words, but only for syntactic forms (not types) => integer is not reserved word (but why?) ** Overview of Language -big, so won't be able to describe it in detail or completely focus on types, packages, exceptions, concurrency *** Syntactic units: An Ada program is a (main) procedure, and whatever subprograms and packages its uses from a library. Program units (modules): tasks (parallel processes) subprograms (procedures and functions) packages (modules) generics All program units are library units, with the exception of tasks! Tasks must be nested in procedure or package. All program units nest. Packages and tasks are split into an interface decl ("specification") and a body, which can be compiled separately. (contrary to first example in book, cannot have both together.) Statements and blocks also nest (unlike Pascal, can have local blocks) Each program unit, block, record declaration, etc. forms a scope **Scope rules: (as in Algol 60) In a scope, declarations in current and outer scopes are visible. Declarations in current block visible after point of definition. (possible to have incomplete declarations...) Packages are used for information hiding and explicitly say what declarations are visible from outside. types may be exported as private (name only). Exported components of package named explicitly: ------------------ stack.pop(f); ------------------ or can imported to be used without prefix of package name by a USE statement