Java: Just Another Version of Ada an overview of Ada 2005

Similar documents
Lecture Notes on Programming Languages

CPS 506 Comparative Programming Languages. Programming Language

Concepts of Programming Languages

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Topics in Object-Oriented Design Patterns

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Inheritance (Chapter 7)

The Structuring of Systems Using Upcalls

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Concurrency. Lecture 14: Concurrency & exceptions. Why concurrent subprograms? Processes and threads. Design Issues for Concurrency.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Performance Throughput Utilization of system resources

Chapter 13 Topics. Introduction. Introduction

What are the characteristics of Object Oriented programming language?

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Programming Languages Third Edition. Chapter 7 Basic Semantics

Data Abstraction. Hwansoo Han

CSC 533: Organization of Programming Languages. Spring 2005

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

An Information Model for High-Integrity Real Time Systems

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

New Programming Paradigms

Green Hills Software, Inc.

Programming Languages for Real-Time Systems. LS 12, TU Dortmund

Concepts of Programming Languages

Programming. In Ada JOHN BARNES TT ADDISON-WESLEY

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru Department of Electronics and Communication Engineering

Asynchronous Event Handling and Safety Critical Java

Advanced Object-Oriented Programming Introduction to OOP and Java

Safety SPL/2010 SPL/20 1

15CS45 : OBJECT ORIENTED CONCEPTS

Chapter Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level

Object-oriented Programming. Object-oriented Programming

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Inheritance and Substitution (Budd chapter 8, 10)

Inheritance and Interfaces

Object Oriented Paradigm

wait with priority An enhanced version of the wait operation accepts an optional priority argument:

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

CMPT Data and Program Organization

Analysis and Design with the Universal Design Pattern

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

Object-Oriented Design

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

A Case Study for HRT-UML

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

Threads SPL/2010 SPL/20 1

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

CS 480 Fall Runtime Environments. Mike Lam, Professor. (a.k.a. procedure calls and heap management)

CMSC 433 Programming Language Technologies and Paradigms. Concurrency

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

Programming Languages, Summary CSC419; Odelia Schwartz

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

CS Programming In C

On 17 June 2006, the editor provided the following list via an to the convener:

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM)

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Multi-threaded programming in Java

Chapter 1. Preliminaries

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

DOT NET Syllabus (6 Months)

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Inter-process communication (IPC)

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

The Procedure Abstraction

Object-Oriented Programming

The Real-time Specification for Java

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

Concurrent Programming using Threads

From MDD back to basic: Building DRE systems

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

D Programming Language

C++ for System Developers with Design Pattern

ASSIGNMENT- I Topic: Functional Modeling, System Design, Object Design. Submitted by, Roll Numbers:-49-70

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

G Programming Languages - Fall 2012

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Dealing with Issues for Interprocess Communication

Runtime Environments I. Basilio B. Fraguela

0. Overview of this standard Design entities and configurations... 5

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Introduction to Object-Oriented Programming

Software Architecture

PROCESSES AND THREADS

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

The basic operations defined on a symbol table include: free to remove all entries and free the storage of a symbol table

Advanced Topics in Operating Systems

Appendix A - Glossary(of OO software term s)

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

OPERATING SYSTEM. Chapter 4: Threads

Transcription:

Topics To Be Covered!Introduction Java: Just Another Version of Ada an overview of Ada 2005 Jorge L. Díaz-Herrera, Ph.D. Professor of Computer Science B. Thomas Golisano College of Computing and Information Sciences Ada design goals One-minute history Core Language Static Structure Dynamic Structure Ada vs. Real-time Java Conclusions Rochester Institute of Technology Tel: 585-475-4786 E-mail: jdiaz@gccis.rit.edu 2 Ada Design Goals A One-Minute History 1 International competition (1) Development as a human activity: Want to write defect-free software? A complex language, but simpler than C++ and even Java A self-contained deployment environment Highly portable (does not depend on target platform) Component-based development Efficiency not an issue Ironman Strawman (2) From building to growing software Tinman SofTech Woodenman requirements (1975.. 1977) 3 Intermetrics SRI Honeywell!Ada design phase (1977.. 1979) 4

Preliminary Ada Reference Manual maturation phase 1979.. A One-Minute History 2 Revised Ada Reference Manual 1982 D o D di ANSI Ada Reference Manual MIL-STD 1815A Ada 9X Revision Requirements standardization phase Ada 9X Mapping Ada 9X ISO Draft 1983.. 1987 1991 1995 ISO 865 ISO 8652-95! Ada 2005 The Ada Standard Three documents Ada Reference Manual Annotated Ada Reference Manual - The language (13 chapters, ~550 pages) - The Standard Libraries - The 17 annexes (~500 pages) Ada Rationale - Programming paradigms - The core language - The annexes 5 6!Introduction Topics To Be Covered!Core Language what is an Ada program? strong typing Static Structure Dynamic Structure Ada vs. Real-time Java Conclusions What is an Ada Program? An Ada program is a set of partitions, each of which may execute in a separate address space, possibly on a separate computer a partition is constructed from library units. Composed of one or more program units - physically nested and hierarchically organized independently provided (program library) Program text can be submitted in one or more compilations. 7 8

Core Language Lexical elements: Block-structured, Strong typing, Exceptions, Typed signatures Structural elements: Packages, Child units, Subprograms, and Interfaces Object-oriented programming: Inheritance, encapsulation, dynamic binding, Identity, explicit overriding Concurrent programming: Tasks, Synchronization, Priorities Real-time and fault tolerance: Clocks, Scheduling control, Security, Hardware access Distributed computing: Partitions (VN), RPC Types In Ada, every type is either specific (a node in a class hierarchy), class-wide (an entire class hierarchy), or Universal (scalar or composite) Strong Typing: Each type in a class is identified by a tag, held by each object belonging to the type. Access types [G. Booch, 1991, p.60] 9 10 Topics To Be Covered!Introduction!Core Language!Static structure design-by-composition design-by-decomposition design-by-extension design-by-adaptation Dynamic structure Ada vs. Real-time Java Conclusions Context (dependency) Concept (services) Software Components Component dependency (context) S Component specification (services) Component body (implementation) Contents (implementation) 11 12

B A Directed Acyclic Graph child unit (Spec) Static Structure Summary D B11 C B12 B1 A B library unit (spec) with (context) subunit (body) C S Design-by-Composition Component (C) becomes client of another server component (S) by importing services offered by the latter. package S is -- exported (i.e., visible) specification end S; package body S is -- implementation follows end S; S subunit (refinement) with S; -- component C -- component C body C 13 14 P.Q P Design-by-Decomposition Any library package P may have child unit P.Q Any component body P (i.e., secondary unit) B P.Q B may contain local units implemented separately a.k.a. subunits S. Results in a tree-like parent-child hierarchy of child units and/or subunits built top-down and rooted at root library unit P S C S Design-by-Extension A component becomes an extension of another component by inheriting services offered by the latter. Results in a treelike class hierarchy built strictly top down C 15 16

C Design-by-Adaptation A component I is an instance of a component template G by providing parametric values specified by the latter. B S I G Instance specializes services Contract: If an actual parameter satisfies the requirements of the corresponding formal parameter, then a body B that matches the formal specification will work Object-Oriented Programming Preserve Ada s strengths for building safe systems Distinction between specific and class-wide types Static binding by default, dynamic binding only when necessary Strong boundary around modules: A class is a package exporting a tagged type Enhance object-oriented features Multi-package cyclic type structures Multiple-inheritance type hierarchies Concurrent OOP 17 18 Static Polymorphism type T1 is new T; -- inherits from T type T2 is new T; -- inherits from T type T11 is new T1; -- inherits from T and T1 type T21 is new T2; -- inherits from T and T2 A class rooted at a type T consists of T and all of its derivatives All types of a class rooted at T have at least the same set of operations as T T11 T1 T T2 T21 Dynamic Polymorphism -- Class-wide operations procedure Write (X: T CLASS) is begin Print (X);-- dispatches method at run-time!!! -- (assuming Print is overloaded)!!! -- based on actual type of X end Write; T procedure Output (X: T1 Class) is begin (X) T11 T1 T2 T21 19 20

Late (run-time) Binding -- Access-To-Subprogram Types: subprograms as data type Button is private; type Resp is access procedure (B: T); procedure Set_Up (B:out Button;R: Resp); procedure Default (B: T); type Button is record R : Resp := Default ACCESS; end record; Generic Class Parameters It is the combination of generics and inheritance that exploits the full potential of reuse generic type T is new Rectangle; -- Rectangle operations imported implicitly package Pk is ; package N_Pk is new Pk (Cuboid); generic -- another example type B is new BOOLEAN; -- boolean operations imported implicitly package Pk is ; Cuboid Rectangle Rectangle CLASS 21 22 Interfaces Similar to abstract types but with multiple inheritance May be used as a secondary parent in type derivations Have class-wide types Support for composition of interfaces type Model is interface; Interfaces: Example type Observer is interface; procedure Notify (O: access Observer; M: access Model Class)!!!! is abstract; type View is interface and Observer; procedure Display (V: access View; M: access Model Class)!!!! is abstract; type Controller is interface and Observer; procedure Start (C: access Controller; M: access Model Class)!!!! is abstract; procedure Associate (V: accessview Class; C: access Controller Class; M: accessmodel Class); Pascal Leroy, IBM 23 24

Interfaces: Example (cont d) type Device is tagged private; procedure Input (D: in outdevice); type Mouse is new Device!!!!!! and Controller with private; procedure Input (D: in out Mouse); procedure Start (D: access Mouse;!!!!!!! M: access Model Class); procedure Notify (D: access Mouse;!!!!!!! M : access Model Class); Concurrent OOP Unify concurrent programming and objectoriented programming Tasks are types (hence objects) Interfaces may specify synchronization properties Procedures may be implemented by task entries task type Counter is entry Increase (By : POSITIVE); entry Decrease (By : POSITIVE); entry Get (Count : out NATURAL); end Counter; 25 26 Ada supports explicit task communication in the form of an essentially procedural interface between exactly two tasks Achieved by a task (client) making entry calls to another task (server) accepting them Client Task Interaction entry call data flow Server!Introduction Topics To Be Covered!Core Language!Static Structure!Dynamic Structure partitions and processes systems and real-time programming Ada vs. Real-time Java Conclusions 27 28

Distributed Ada Execution An executable system is a cooperating set of one or more active partitions zero or more passive partitions Partition: a partition is a program or part of a program that can be invoked from outside the Ada implementation 10.2/2 A Distributed Ada System active partition 1 processor passive partition 1 RCI package active partition n processor passive partition m 29 30 Heavyweight Process The execution of an Ada program does not require an operating system partition main subprogram subunits library units library units secondary units partition main subprogram subunits library units library units secondary units Topics To Be Covered!Introduction!Core Language!Static Structure!Dynamic Structure data E.T. data!ada vs. Real-time Java Conclusions Runtime System 31 32

Ada & Real-time Programming Language features promoting safety/reliability and deterministic language semantics (predictability) Concurrency Well-defined semantics for scheduling Safe / efficient mutual exclusion, including state notification Safe / efficient coordination / communication Hardware control Safe/predictable Memory management Asynchronous events / event handlers Asynchronous Transfer of Control (interrupts) Support for high-resolution time (millis and nanos), both absolute and relative Support for various kinds of timers, clocks Access to hardware-specific features Java Summary Pure Object-Oriented language in the style of Smalltalk Single inheritance of classes, multiple inheritance of interfaces Built-in support for exception handling, threads Well-defined semantics, at least for sequential features Classes are run-time objects All non-primitive data go on the heap Emphasis on safety, security (downloadable applets ) Garbage collection required Portable, interpretable binary format for Java classes Core libraries, and extensive set of packages for a wide variety of application domains 33 34 Java for Real-time? 1* Thread method is error prone (Effect not always clear from source syntax) Requires cooperation by the accessing threads - Even if all methods are synchronized, an errant thread can access non-private fields without synchronization - A non-synchronized method may be safe to invoke from multiple threads, but a synchronized method might not be safe to invoke from multiple threads - Not always clear when a method needs to be declared as synchronized Complex interactions with other features (e.g. when are locks released?) Locking is hard to get right (exacerbated by absence of nested objects) Java for Real-time? 2* Limited mechanisms for direct inter-thread communication wait()and notify()/notifyall()are low-level constructs that must be used very carefully Synchronized code that changes object s state must explicitly invoke notify()/notifyall() No syntactic distinction between signatures of synchronized method that may suspend a caller and one that does not Only one wait set per object (versus per associated condition ) Public thread interface issues The need to explicitly initiate a thread by invoking its start() method allows several kinds of programming errors Although run()is part of a thread class s public interface, invoking it explicitly is generally an error (*) Adapted from Ben Brosgol, Aonix 35 (*) Adapted from Ben Brosgol, Aonix 36

Java for Real-time? 3* Lack of some features useful for software engineering Operator overloading strongly typed primitive types, Scheduling deficiencies Priority semantics are implementation dependent and fail to prevent unbounded priority inversion Section 17.12 of the Java Language Specification: Every thread has a priority. threads with higher priority are generally executed in preference to threads with lower priority. Such preference is not, however, a guarantee that the highest priority thread will always be running, and thread priorities cannot be used to reliably implement mutual exclusion. Java for Real-time? 4* Memory management unpredictability Predictable, efficient garbage collection appropriate for real-time applications not (yet) in mainstream lacks stack-based objects Heap used for exceptions thrown implicitly as an effect of other operations Asynchrony deficiencies Event handling requires dedicated thread interrupt()not sufficient stop()and destroy()deprecated or dangerous or both (*) Adapted from Ben Brosgol, Aonix 37 (*) Adapted from Ben Brosgol, Aonix 38 Java for Real-time? 5* OOP has not been embraced by the real-time community Dynamic binding complicates analyzability Garbage Collection defeats predictability A class s interface is more than its public and protected members Real-time Java History* No features for accessing underlying hardware Performance questions Standard API would need to be rewritten for predictability In general it includes some implementation characteristics E.g. does it allocate objects, can it block Some JVM opcodes require non-constant amount of time (*) Adapted from Ben Brosgol, Aonix 39 (*) Adapted from Ben Brosgol, Aonix 40

Scheduling-related classes (partial list)*!introduction Topics To Be Covered!Core Language!Static Structure!Dynamic Structure!Ada vs. Real-time Java!Conclusions (*) Adapted from Ben Brosgol, Aonix 41 42 Conclusions Ada easier to restrict for building safety-critical systems (the features that makes creating solid applications possible) very successful in the safety-critical domain (high reliability military and space applications) Java many safety-critical issue are intrinsic (pure OOP) C-based syntax prone to errors (hybrid type system) has not be used in the safety-critical domain In Summary Ada is a much better technical solution for implementing safety-critical distributed, concurrent systems powerful, semantically complete, well-designed There are a number of compilers including commercial development systems (AdaCore, Aonix, Artisan Software, Green Hills Software, IBM, and Polyspace technologies) There are some deficiencies Availability of Ada programmers Ada is worth another look! 43 44

The Future: Ada 2005 and beyond The JTC1/SC22/WG9 ISO Working Group in charge of maintaining the Ada Language http://www.open-std.org/jtc1/sc22/wg9/ AdaRapporteur Group collecting Ada Issues http://www.ada-auth.org/arg-minutes.html Ada Conformity Assessment Authority http://www.ada-auth.org/ Resources GNAT Academic Program (Open source) http://www.adacore.com/home/academia/ http://libre2.adacore.com SIGAda WWW Server Home Page http://www.acm.org/sigada/ Ada Home: The!Web!Site!for!Ada http://www.adahome.com/ Ada CORBA Products http://www.adapower.com/corba/ A#: Ada for.net http://www.usafa.af.mil/df/dfcs/bios/mcc_html/a_sharp.cfm 45 46 Aonix http://www.aonix.com Resources 2 Comparison Chart* Artisan Software http;//www.artisansw.com Green Hills Software http://www.ghs.com IBM http://www.ibm.com Polyspace Technologies http://www.polyspace.com 47 (*) from Adacore technologies 48

Comparison Chart* (*) from Adacore technologies 49