Computer

Ada: Real Time Programming Language

Ada: Real Time Programming Language

Ada: Real time programming language

Ada is a modern programming language designed for large, long-lived applications and embedded systems in particular where reliability and efficiency are essential. Ada is the only ISO-standard, object-oriented, concurrent, real-time programming language. Real-time programming language used in real-time system where the correctness of the computations not only depends on their logical correctness, but also on the time at which the result is produced.

Ada is multi-faceted. From one perspective it is a classical stack-based general-purpose language, not tied to any specific development methodology. It has a simple syntax, structured control statements, flexible data composition facilities, strong type checking, traditional features for code modularization (“subprograms”), and a mechanism for detecting and responding to exceptional run-time conditions (“exception handling”). Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages. It has built-in language support for design-by-contract, extremely strong typing, explicit concurrency, offering tasks, synchronous message passing, protected objects, and non-determinism. Ada aims to improve the safety and maintainability by leveraging the compiler to find compile-time errors in favor of runtime errors. Ada is an international standard; the current version (known as Ada 2012) is defined by ISO/IEC 8652:2012.

GNAT Programming Studio is widely used in Ada development.

Ada Features Summary

  • Object orientated programming
  • Strong typing
  • Abstractions to fit program domain
  • Generic programming/templates
  • Exception handling
  • Facilities for modular organization of code
  • Standard libraries for I/O, string handling, numeric computing, containers
  • Systems programming
  • Concurrent programming
  • Real-time programming
  • Distributed systems programming
  • Numeric processing
  • Interfaces to other languages (C, COBOL, Fortran)

Ada has built-in features that directly support: Structured programming, Object-oriented programming, Generic programming, Distributed programming, Concurrent programming.

Data types:

  • A Type is given by a set of values and their operations.
  • Ada allows us to define our own data types, including numeric data types.
  • The elementary Ada types are:
    • Scalar Types : The predefined package Standard contains declarations for the standard types such as integer, float, character and boolean, as well as defining the operations available on them. These operations are defined for all scalar types : =, /= Equality, inequality, <, <=, >, >=, in, not in Range membership text
    • Discrete Types : Integers types are Discrete type. Here the standard predefined integer type is used. Count : Integer; X,Y,Z : Integer; Amount : Integer := 0; Unity : constant Integer := 1; A_Month : Integer range 1..12;
    • Real Types : Floating types are Real type. The following are examples of floating point declarations. Example : x    : float;  a,b,c: float;  pi: constant float := 3.14; Avogadro : constant := 6.027E23;
    • Fixed Point Types
    • Access Types

Control Structures:

The control structures of Ada are similar in style to most conventional languages. However some differences remain.

ifcondition then

statement;

else

other statement;

end if;

 

Case Statements: Case statement in Ada can be define as follows

case X is

            when 1 =>

            Walk_The_Dog;

            when 5 =>

                        Launch_Nuke;

                        when 8 | 10 =>

                        Sell_All_Stock;

                        when others =>

                        Self_Destruct;

                        end case;

Loop Statements :Loop  statements in Ada are

  • Endless Loop
  • Loop with Condition at the Beginning
  • loop with condition at the end
  • loop with condition in the middle
  • for loop

For loop Example is following :

for I in Integer range 1 .. 10 loop

                        Do_Something (I)

                        end loop For_Loop;

Here is simple complete example of Ada:

Calculate (int *a, *b) {

int c, d; c=*a++; d=c*a/*b; a=d+(*a)-b;

}

procedure Calculate (a : in out Integer; b : in Integer) is c, d : Integer;

begin

c := a;

a := a + 1;

d := c * a / b;

a := d + a – b;

end Calculate;

Several options exist for providing an environment for the development of Ada-language programs. Some useful environments are listed below.

  • APSE : APSE is short for Ada Programming Support Environment. APSE was a U.S. Military specification for developing a programming environment that would support the Ada programming language and Ada-related programming tools.
  • Emacs Ada-Mode :Emacs is an easily-customized highly-extensible text-editor. Emacs includes a module for Ada-language support as part of the Emacs standard distribution, called ‘Ada-mode’. Emacs is available for many Linux distributions as a binary or source package. Emacs is available as a binary installer for Windows, and is also available as an OS agnostic source code package. The Emacs website includes a description of ‘Ada-mode’ as well as installation and configuration instructions for different operating systems, including a guide to customizing Ada-mode to personal taste.
  • GPS : GPS is an acronym for the GNAT Programming Studio. GPS is a fully-featured integrated development environment. It includes support for multiple platforms and languages, and modern programming tools including a language sensitive editor, graphical debugger, automatic code fixing, and support for version control systems. GPS is supported by AdaCore, and comes with large amount of online documentation, including an online user guide and tutorial. AdaCore also maintains a port of the GUI toolkit GTK called GtkAda, which provides for the development of rich, GUI-based applications with Ada.
  • Atego :Atego’s editions of ObjectAda include compilers and tools for various targets, a programmable debugger, a language sensitive editing environment, and also an Eclipse plugin. ApexAda continues the full lifecycle environment offered with this former Rational/IBM Ada.

Why consider Ada for safety/security-critical software :

  • Reliability
    • Very few features have surprising effects
      • Prevention of dangling references to declared objects, subprograms
      • Specification of intent on operation inheritance
    • Contracts
    • No garbage collection
      • Programmer responsible for memory management
      • Predictability
    • Language semantics are generally well-defined, in an ISO standard
      • But there are features whose effects are implementation defined, implementation dependent, unspecified, or “bounded errors”
    • Implementation decisions can affect time or space predictability
      • Functions returning unconstrained arrays
    • Solutions in practice
      • Analyze source program (e.g. no read of uninitialized object)
      • Adhere to subset (no functions returning unconstrained arrays)
      • Analyze object code so that implementation decision is known
    • Analyzability
      • Some features help analyzability
        • Child units may be used for testing packages with encapsulated state
      • But full language is too complex; need to subset
      • Key features are pragma Restrictions and pragma Profile
        • Ada is in effect a family of profiles, where user can select features à la carte
        • No such thing as the safety-critical Ada profile
        • Troublesome OOP features are easily avoided
      • But no standard annotation facility
      • Expressibility
      • Support for low-level and real-time programming
      • Ravenscar Profile for certifiable concurrent applications
      • Good inter-language interfacing facilities, to incorporate certifiable libraries from other languages
      • Some weaknesses
        • Limited support for distribution / networking

Ada evaluation :

  • Strengths
    • Sound base language for programming high-reliability systems
    • Allows construction of tailored high-integrity subsets that are:
      • Powerful enough to use for real systems
      • Simple enough to be amenable to certification
    • Scales up to large systems
    • ISO Standard
    • Concurrency support / Ravenscar Profile
    • Design by contract
    • Free and publicly available documents
      • Ada Reference Manual, Rationale
      • Guidelines documents
    • Good track record in avionics, train control, other safety-critical domains
  • Weaknesses
    • Whole language is too large, so must be subsetted
      • Aside from the standard Ravenscar Profile, others are vendor specific
    • Language has some features with implementation-dependent or unspecified behavior
      • Such as referencing a variable before its initialization
    • Smaller user / tool vendor community than other languages

z1

Ada Benefits Summary:

Ada gives some great benefit in soma major domain in development. Thesebenefit are mention below

  • Helps us design safe and reliable code
  • Reduces development costs
  • Supports new and changing technologies
  • Facilitates development of complex programs
  • Helps make code readable and portable
  • Reduces certification costs for safety-critical software

 

Ada is seeing significant usage worldwide in the high-integrity and safety-critical domains including commercial and military aircraft avionics, air traffic control, railroad systems, and medical devices. With its embodiment of modern software engineering principles Ada is an excellent teaching language for both introductory and advanced computer science courses, and it has been the subject of significant university research especially in the area of real-time technologies.

From the programmers perspective, the role of the programming language is to offer leverage: developers will do their jobs more effectively and efficiently when the language they are using offers better support for the various “ilities” (readability, maintainability, portability, etc.) These are precisely the goals that Ada was designed to meet, and which it has been achieving successfully for nearly twenty years in large, long-lived systems worldwide.