240 likes | 248 Views
An overview of programming languages and systems concepts, including language taxonomy, design principles, and the differences between compilers and interpreters. This course is geared towards graduate students lacking a computer science undergraduate degree.
E N D
CSI 511 - Fall 2002 Dr. William A. Maniatty Assistant Prof. Dept. of Computer Science University At Albany Programming Languages and Systems Concepts Fall 2002 Monday Wednesday 2:30-3:50 LI 99
Administrative Stuff Grading Policy • Grading Scale as per Syllabus • 2 Exams, 25 % each (Midterm and Final) • 4 Projects, 10% each • 1 Presentation 10% This is a Graduate Course, for Researchers • Oriented to CS grads lacking CS undergrad • Review Classical and Current Literature • Explore state of the art
Goals of the Course What is a programming Language? • A notation used to express programs (source code) • A framework in which programs run • Compilation - Program translated into another language and executed. • Interpreter - Program is evaluated on the fly. • Not the Operating System (Run time).
Prerequisites • Mathematics • Graph Theory • Combinatorics • Computer Science • Automata Theory • Computer Architecture • Data Structures/Algorithms • Miscellaneous • Technical Writing
Who Should Take this Course? • To succeed you should have: • Motivation -Willing to work hard • Preparation - Have good background • Aptitude - Ability to learn and get results • Should have a B or better average in • Data Structures • Discrete Math • Computer Architectures
Academic Honesty • Our reputation is all we have got. • I want my students to do well. • We Need Employer's and School's Trust • Cheaters subject to failure and sanctions. • So Protect our Reputation • Try projects early • If stuck see TA or the Prof. • Set an example and encourage integrity • Don't panic, some assignments are hard • To test limits of the best students.
Design Principles • Technical Factors • Ease of use • Problem type (Form Follows Function) • Expressiveness (How general is it?) • Ease of writing good interpreter/compiler • Performance • Flexibility/Evolution (established languages) • Non Technical Factors • Inertia • Large Supporters/Visibility (new languages) • Compiler/Interpreter Availability • Personal Preference/Evangelism
Programming Language Taxonomy • Imperative (Focus on Control Flow) • Procedural (von Neuman) • Object Oriented • Declaritive • Functional • Data Flow • Logic, Constraint Based
Imperative Languages • Focus on Control Flow (Instructions) • Procedural (von Neumann) • Describes Actions on data • Assembly, Fortran, Basic, Pascal, C, Bourne Shell • Object Oriented • Language Support for Grouping Data and Operations Together (Encapsulation) • Simula 67, Small Talk, C++ (Hybrid), Eiffel, Java
Declarative Languages • Declarative = Data Driven • Functional - Based on Churches Lamda Calculus: Lisp, ML, Haskell • Data Flow -Pipelined data operations • Logical, Constraint Based - Give rules and initial condition, derive path to goal. • Prolog and Spread Sheets (Visicalc/Lotus/Excel) • Relational -Database Query - SQL
Why Should I study Programming Languages? • To allow Informed Design Decisions • Gives insight when debugging • Permits effective use of compilers/linkers interpreters and language oriented tools. • Helps to understand how langauge features work. • Learn features, emulate missing features.
Binding Time • Binding assigns values to language objects • Instruction Addresses • Data Values • Data Addresses • Binding can be • Early - Performance improved • Late - Increased Flexibility
Compilers Vs. Interpreters • Is Translation Separate from Execution? • Yes -Compiler • No - Interpreter • Combined Approach Often Used (Java)
Why Interpret? • Flexibility (provided by late binding) • Run Time Environment Support • Scripting (Perl, Shells, Python,TCL) • Dynamic Environments (Basic, APL, LISP) • Virtual Machines (JVM, Emulators, CPUs).
Why Compile? • Fundamental Engineering Principles • Correctness -Early static error checking • Cost -Can reduce cost of code distribution • Performance - Make the common case fast • Compile Once (Cost) , Run Many Times (Benefit)
Multi-Pass Compilers • How to handle complexity? • Libraries (keep language simple, e.g. Java) • Layering (Focus on one problem at a time) • Results in Multiple (pipelined) phases
Intermediate Code • Some Optimizations easier at that level • Portability Easier (Pascal) • Intermediate Code Can be Interpreted
Target Languages • Many compilers emit assembly code • Can be highly optimized • Others emit higher level langauges • Exploits existing optimizers • Increases Portability, reduces complexity
Phases of Compilation • Layering induces phases of compilation
An Example • Consider the Pascal Program
Syntax Analysis (Front End) • Scanning identifies terminals (tokens) • Parsing identifies nonterminals
Semantic Analysis • Semantic Analysis is back end • Uses Abstract Syntax Tree (AST)
Optimization • Goal: Reduce Resource Consumption • Memory (data and/or instructions) • Run Time • Golden Rule: Never break working code. • Sad Truth: Most programs are broken. • No guarantees about broken programs
Summary • We will focus on imperative languages • They are by far more common • But we will look at Declaritive approaches too • Want to understand design and implementation • Explore common techniques • Often with imperative language application