Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Organization of Programming Languages-Cheng (Fall 2005) Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2005.

Similar presentations


Presentation on theme: "1 Organization of Programming Languages-Cheng (Fall 2005) Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2005."— Presentation transcript:

1 1 Organization of Programming Languages-Cheng (Fall 2005) Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2005

2 2 Organization of Programming Languages-Cheng (Fall 2005) Why are there so many programming languages? u Evolution -- we've learned better ways of doing things over time u Socio-economic factors: u Proprietary interests, u Commercial advantage orientation toward special purposes u Orientation toward special hardware u Diverse ideas about what is pleasant to use

3 3 Organization of Programming Languages-Cheng (Fall 2005) What makes a language successful? u Ease of use: Easy to learn (BASIC, Pascal, LOGO, Scheme) Easy to express things Easy to use once fluent -- "powerful" (C++, Common Lisp, APL, Algol-68, perl) Easy to implement (BASIC, Forth) possible to compile to very good (fast/small) code (ForTran) u Cost factors: Backing of a powerful sponsor (COBOL, PL/1, Ada, Visual Basic) Wide dissemination at minimal cost (Pascal, Turing, Java)

4 4 Organization of Programming Languages-Cheng (Fall 2005) Why do we have programming languages? u Programmer’s perspective: way of thinking way of expressing algorithms languages from the user's point of view u Abstraction of virtual machine way of specifying what you want the hardware to do without getting down into the bits languages from the implementor's point of view Course Objective: balance coverage of two angles. Commonalities and differences among languages Implementations of languages

5 5 Organization of Programming Languages-Cheng (Fall 2005) History of Programming Languages http://www.webopedia.com/TERM/P/programming_language.html

6 6 Organization of Programming Languages-Cheng (Fall 2005) Detour into Dr. Cheng’s background u Freshman year at Northwestern Univ in 1981: First programs written in Fortran IV Typed programs onto punch cards Computer used: CDC Cyber (size of 2-3 fridges) Terminal used: card punch machine u End of first quarter, exposed to new language -- Pascal u Second quarter: computer organization class Learned PDP-11 assembly language Computer used: PDP-11 machine (size of 1 fridge)

7 7 Organization of Programming Languages-Cheng (Fall 2005) More of the detour u Subsequent courses in undergrad mostly in Pascal (structured programming, data abstractions, etc.) u AI course exposed to LISP. u Graduate course taken as undergrad exposed to Prolog (as part of AI and theorem proving). u Graduate school at UIUC (1985) Exposed to Unix and C. Shared office with Smalltalk research group. C++ was just gaining popularity, along with OO

8 8 Organization of Programming Languages-Cheng (Fall 2005) End of Detour … u Industry experience: Boeing (Fortran and Pascal) (1982-83) IBM (version of PL/I) (1984) Data General (Pascal, C) (1985) Digital ( C ) (1986) u Fast forward to start at MSU (1990): First quarter taught Org. of Programming Languages: (C, LISP, Prolog, C++) Java introduced in early 1990s Web takes off in mid 1990s. Mobile computing, cross platform computing, etc. 2004-05: multi-paradigm languages, heterogeneous platforms, “anytime, anywhere” computing

9 9 Organization of Programming Languages-Cheng (Fall 2005) Major Influences to Programming Languages u Computer Architecture Von Neumann Architecture u Programming methodologies Programming paradigms

10 10 Organization of Programming Languages-Cheng (Fall 2005) Von Neumann Architecture

11 11 Organization of Programming Languages-Cheng (Fall 2005) Influence of Computer Architecture u Memory cells u Pipelined execution of instructions u Variables u Computation is viewed as a sequence of actions Computer ArchitectureProgramming Language  

12 12 Organization of Programming Languages-Cheng (Fall 2005) Programming Paradigms Imperative Procedural (von Neumann)ForTran, C, Basic, Pascal, Algol60 Object-OrientedSimula67, C++, Smalltalk, Java, C# Declarative FunctionalLISP, Scheme, ML, Haskell LogicalProlog, VisiCalc, RPG, spreadsheets

13 13 Organization of Programming Languages-Cheng (Fall 2005) Desirable Qualities of Software Software must be reliable  Program performs to its specification under all conditions Software must be maintainable  It is no longer feasible to always build software from scratch  Must be able to easily modify existing software Software must execute efficiently  Although hardware getting cheaper and has better performance, need for efficient execution remains due to increasingly demanding applications

14 14 Organization of Programming Languages-Cheng (Fall 2005) Why study programming languages? u Help you choose a language. C v. Modula-3 v. C++ for systems programming Fortran v. APL v. Ada for numerical computations C v. Ada v. Modula-2 for embedded systems Common Lisp v. Scheme v. ML for symbolic data manipulation Java v. C/CORBA for networked PC programs

15 15 Organization of Programming Languages-Cheng (Fall 2005) Why study programming languages? u Make it easier to learn new languages (by analogy) some languages are similar; easy to walk down family tree (e.g., ForTran 77, ForTran90) Identify common concepts :  E.g.: iteration, recursion, abstraction Think of an analogy to human languages:  good grasp of grammar makes it easier to pick up new languages (at least romance languages).

16 16 Organization of Programming Languages-Cheng (Fall 2005) Make better use of language u Understand obscure features: In C, help you understand unions, arrays & pointers, separate compilation, varargs, In Common Lisp, help you understand first-class functions/closures, streams, catch and throw, symbol internals

17 17 Organization of Programming Languages-Cheng (Fall 2005) Make better use of language u Understand implementation costs: choose between alternative ways of doing things, based on knowledge of what will be done underneath:  Use simple arithmetic equalities (use x*x instead of x**2)  Use C pointers or Pascal "with" statement to factor address calculations –avoid call by value with large data items in Pascal –avoid the use of call by name in Algol 60 –choose between computation and table lookup

18 18 Organization of Programming Languages-Cheng (Fall 2005) Make better use of given language u Figure out how to do things in languages that don't support them explicitly: Lack of suitable control structures in Fortran IV  use comments and programmer discipline for control structures Lack of recursion in Fortran 77, CSP, etc.  write a recursive algorithm then use mechanical recursion  elimination (even for things that aren't quite tail recursive)  lack of named constants and enumerations in Fortran use variables that are initialized once, then never changed  lack of modules in C and Pascal use comments and programmer discipline  lack of iterators in just about everything fake them with (member?) functions

19 19 Organization of Programming Languages-Cheng (Fall 2005) Language Design Criteria u Simplicity Simpler language is easier to master Achieved by having a small number of features Feature multiplicity:  more than one way to accomplish the same task  E.g.: count++; count = count + 1; count += 1 Operator overloading:  same operator has more than one meaning  Overload “+” operator for Summing integers in two arrays Concatenating two arrays

20 20 Organization of Programming Languages-Cheng (Fall 2005) Language Design Criteria u Orthogonality Every possible combination of primitive constructs of the language is legal and meaningful Lack of orthogonality means lots of exceptions in the language rules  Assembly language for IBM mainframe: A Reg1, memory cell Two different rules for addition AR Reg1, Reg2 Cannot use A for adding 2 registers Too much orthogonality makes language become overly complex (Algol 68)

21 21 Organization of Programming Languages-Cheng (Fall 2005) Language Design Criteria-Syntax u Identifier forms Fortran77 restricts identifiers to ≤6 characters u Special words Pascal requires begin-end pairs to form groups for all control constructs Ada uses “end if” or “end loop” to distinguish closing syntax for each type of control statement Fortran 90 allows special words such as DO and END to be legal variable names

22 22 Organization of Programming Languages-Cheng (Fall 2005) Language Design Criteria u Safety Language should not provide features that make it possible to write harmful programs  E.g., goto statements and pointer variables Type checking  testing for type errors in a given program, during compilation or program execution Aliasing  Having two or more distinct referencing methods, or names, for the same memory cell (e.g., union members, pointers in C) u Robustness Provides the ability to deal with undesired events (arithmetic overflows, invalid input, etc)  E.g., Exception handling facility in Java and C++

23 23 Organization of Programming Languages-Cheng (Fall 2005) Language Design Criteria Portability:  Programs can be compiled and run on different machines without rewriting the source code Uniformity:  Similar notations should look and behave in the same way (e.g., every “end” must be preceded by a matching “begin”) Support for abstraction  Ability to define and then use complicated structures or operations in ways that allow many details to be ignored  Process abstraction vs Data abstraction

24 24 Organization of Programming Languages-Cheng (Fall 2005) Design Trade-offs u Reliability vs Efficiency Ada demands all references to array to be checked to ensure that indices are within their legal ranges C does not require index range checking, and thus executes faster Buffer overflow problem void function (char *str) { char buffer[16]; strcpy (buffer, str); } int main () { char *str = "I am greater than 16 bytes"; function (str); }

25 25 Organization of Programming Languages-Cheng (Fall 2005) Design Trade-offs u Flexibility vs Safety Pascal variant records allow a memory cell to contain either a pointer or an integer  This allows a program to do arithmetic on pointers, which is sometimes convenient, but is a dangerous practice.

26 26 Organization of Programming Languages-Cheng (Fall 2005) Course Organization u Lectures material supplement textbook material (i.e., come to class) u Homework assignments reinforce key concepts u Programming assignments give hands-on experience u Exams provide a way for you to demonstrate what you’ve learned (and I need something to use for calculating grades)

27 27 Organization of Programming Languages-Cheng (Fall 2005) Course Organization Homework15% Programming Assignments 30% Exams (2) Exam 1: 10/18/05 Exam 2: 12/13/05 50% In-class participation5%


Download ppt "1 Organization of Programming Languages-Cheng (Fall 2005) Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2005."

Similar presentations


Ads by Google