© Alan Burns and Andy Wellings, 2001 Programming in the Small Aim: to remind you how to read/write programs in Ada 95, Java and ANSI C.

Slides:



Advertisements
Similar presentations
Intermediate Code Generation
Advertisements

Programming Languages and Paradigms
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Programming Languages and Paradigms The C Programming Language.
Slide: 1 Copyright © AdaCore Arrays Presented Quentin Ochem university.adacore.com.
Names and Bindings.
Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
1 Languages and Compilers (SProg og Oversættere) Sequence control and Subprogram Control.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
CS 330 Programming Languages 10 / 18 / 2007 Instructor: Michael Eckmann.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
© Alan Burns and Andy Wellings, 2001 Programming in the Small n Aim: to remind you how to read/write programs in Ada 95, Java and ANSI C n Practicals will.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Type Checking Strong Typing Type Compatibility.
Chapter 9: Subprogram Control
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
Abstract Data Types and Encapsulation Concepts
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
Scope.
© 2003 G. Drew Kessler and William M. Pottenger1 Subroutines (Part 1) CSE 262, Spring 2003.
Language Evaluation Criteria
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Block-Structured Procedural Languages Lecture 11: Dolores Zage.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Porting Implementation of Packet Utilization Standard from ADA to JAVA Annelie Hultman (TEC-EME) Donata Pedrazzani (TEC-EMS) ESA/ESTEC 2004 JPUS de-briefing.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
Basic Semantics Associating meaning with language entities.
Subprograms subroutines, procedures, functions, methods.
Programming Languages and Paradigms Imperative Programming.
Ada How was Ada conceived. The language, not the lady.
Control Structures sequence of execution of high-level statements.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
ICS 313: Programming Language Theory Chapter 14: Exceptions.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Chapter 6 Functions 6.1 Modular Design A valuable strategy when writing complex programs is to break down the program into several smaller modules. A module.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Names, Bindings, and Scope Session 3 Course : T Programming Language Concept Year : February 2011.
Structure of Programming Languages Names, Bindings, Type Checking, and Scopes.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Essential Ada Terminology copyright © Michael B. Feldman, All Rights Reserved.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Abstract Data Types and Encapsulation Concepts
Type Checking, and Scopes
11.1 The Concept of Abstraction
Defining Classes and Methods
Abstract Data Types and Encapsulation Concepts
Control Structures In Text: Chapter 8.
MSIS 655 Advanced Business Applications Programming
Languages and Compilers (SProg og Oversættere)
Overview of Programming Paradigms
11.1 The Concept of Abstraction
Presentation transcript:

© Alan Burns and Andy Wellings, 2001 Programming in the Small Aim: to remind you how to read/write programs in Ada 95, Java and ANSI C

© Alan Burns and Andy Wellings, 2001 Fortran Example DO 20 I = 1, 100 Loop to label 20, iterating I from 1 to 100 On the U.S. Viking Venus Probe, a programmer wrote DO 20 I = The compiler interpreted this as an assignment statement and ignored the spaces DO20I = Variables need not be declared in Fortran, and those beginning with D are assumed to be of type real is a real literal!

© Alan Burns and Andy Wellings, 2001 An Overview of Ada An Ada program consists of one or more program units: a subprogram (procedure or function) — can be generic a package (possibly generic) — used for encapsulation and modularity a task — used for concurrency a protected unit — a data-oriented synchronisation mechanism Library units: package, subprogram Subunits: subprogram, package, task, protected unit

© Alan Burns and Andy Wellings, 2001 Blocks Ada is a block-structured language declare -- definitions of types, objects, -- subprograms etc. begin -- sequence of statements exception -- exception handlers end; A block can be placed anywhere a statement can be placed

© Alan Burns and Andy Wellings, 2001 Points about Blocks objects declared in a block may only be used in that block (scope)‏ any statement in the sequence of statement may itself be a block exception handlers can be used to trap errors arising out of the execution of the sequence of statements (they may be omitted)‏

© Alan Burns and Andy Wellings, 2001 Example function Largest(X : Vector) return Integer is Max : Integer := 0; begin for I in X’Range loop if X(I) > Max then Max := X(I); end if; end loop; return Max; end Largest; ’Range is an attribute and = ’First - ’Last

© Alan Burns and Andy Wellings, 2001 The C Language Is sequential Main structuring units are functions (although files can be used to aid separate compilation)‏ Block structured (called compound statements)‏ { } Declarative part cannot contain functions Sequence of statements can contain compound statement

© Alan Burns and Andy Wellings, 2001 C Example int largest(vector X, int len)‏ { int max = 0; int i; for (i = 0; i < len; i++) { // bounds start at 0 if(X[i] > max) max = X[i]; } return max; } Assignment statement is = Equality is = =

© Alan Burns and Andy Wellings, 2001 An Overview of Java A class-based language Programming in the small component is similar to C but without explicit pointer values More type secure than C As with Ada, Java can have exception handler at the end of a block (but only if the block is a try block)‏ Functions can only be declared in the context of a class

© Alan Burns and Andy Wellings, 2001 class SomeArrayManipulationClass { public int largest(vector X)‏ { int max = 0; int i; for (i = 0; i < X.length; i++) { // bounds start at 0 // length is an instance variable of array objects if(X[i] > max) max = X[i]; } return max; } A Java Example All arrays are objects

© Alan Burns and Andy Wellings, 2001 Java and Reference Types All objects in Java are represented as reference values Comparing two objects will compare their references not their values: Node Ref1 = new Node(); Node Ref2 = new Node();... if(Ref1 == Ref2) {... } will compare the locations of the objects not their values; it is necessary to implement a compareTo method A similar situation occurs with object assignment; it is necessary to provide a clone method

© Alan Burns and Andy Wellings, 2001 Discrete Types