140 likes | 252 Views
Research Project CSC 415 Programming Languages Fall 2013. History. Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other language
E N D
History • Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other language • created in the 1970 for the purpose of the US Department of defense • this decision because they had realized that there were many languages used by the US Department of Defense and created this program to supersede the many different languages they were using
History Cont. • named after the first credited programmer Ada Lovelace • the US Department of Defense was concerned by the number of different programming languages being used for its embedded computer system projects, many of which were obsolete or hardware-dependent, and none of which supported safe modular programming
Data Types • Data types of a programming language are the different types of input and symbols that a programming language can read and work with
Expression & Assignment Statement • Character next_vowel := ‘o’; • Float delta_v_sq:= (v2-v1) **2; • Delta_sum := (delta_v_sq + delta_h_sq) * .10; • angle := 2.0 * pi * float(p) / 360.0; • integer i := i + 1; • natural new_value := abs(any_value) + mod(old_value, 10); • string my_string := “ “ & packname(j) & “-“;
Statement-Level Control Structure • with Ada.Text_IO, ADa.Integer_Text_IO; • use Ada.Text_IO, Ada.Integer_Text_IO; • procedure Example is • Year : INTEGER; • begin • for Age in 0..21 loop • Put("In"); • Put(Age + 1938,5); • Put(", I was"); • Put(Age,3); • Put(" years old"); • case Age is • when 5 => Put(", and started school"); • when 17 => Put(", and graduated from high school"); • when others => null; • end case; • Put("."); • New_Line; • end loop; • end Example;
Object-Oriented Programming • Although the Ada language primary use was for the US Department of Defense, it does support object oriented programming • It does have use interface with buttons, images, audio, and other source of input
Concurrency • Concurrent computation makes programming much more complex • major feature of the Ada programming language is the facilities it provides for concurrent programming
Exception & Event Handling • begin • ... • exception • whenBuffer_Full_Error => • Reset_Buffer; • when Error: others => • Put_Line("Unexpected exception raised:"); • Put_Line(Ada.Exceptions.Exception_Information(Error)); • end;
Example Code • HELLO WORLD! • -- Ada Hello, World! program. • with Text_IO; use Text_IO; • procedure Hello is • Put_Line("Hello, World!"); • end Hello;
Example Code • Function: • with Gnat.Io; use Gnat.Io; • procedure f1 is • -- A small function. • function Sumsqr(X, Y: Integer) return Integer is • begin • return X*X + Y*Y; end; • -- How 'bout a nice, tender variable? • I: Integer; • begin • I := Sumsqr(3, 14); • Put(I); • New_Line; • Put(Sumsqr(I, 4)); • New_Line; • end f1;
Exception Handling Example: • with Ada.Text_IO; use Ada.Text_IO; • procedure ReadOut is • S: String(1..100); -- Input line (up to 100 chars) • N: Integer; -- Number of characters read. • Begin • -- Issue the lovely decoration. • Put_Line("-----------------------------------------------------" & "-----------"); -- Copy lines like there's no tomorrow. • loop • Get_Line(S, N); • Put_Line(S(1..N)); • end loop; • exception • when End_Error => • -- When reaching end of file, issue the closing lovely decoration • and • -- return from the procedure. • Put_Line("-----------------------------------------------------" & "-----------"); • return; • end ReadOut;