The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta, Addison-Wesley, 2010, ISBN
Why study programming languages? Required course... Diverse set of tools in your programming toolbox Increased capacity to express ideas Increased ability to build efficient and easy-to-maintain software systems Why so many languages?
Languages are not entirely general-purpose Business applications (typically distributed) ▪ Process data, output reports, control transactions ▪ Increasingly distributed Manufacturing and control systems ▪ Reliability and non-stop operation Entertainment and Web applications ▪ Wide variety of online and device requirements ▪ Portability
Languages are not entirely general-purpose Scientific applications ▪ Often computationally intensive Artificial intelligence and research applications ▪ Represent and manipulate symbols instead of numbers ▪ Also often computationally intensive Systems and network programming ▪ Operating system and support programs ▪ Requires efficient non-stop operations
How can we evaluate a programming language? Goals of the language Readability Writability Portability Reliability (of the language—e.g. C++ vs. Java) Cost ($$$, training costs, compilation process) Ease of maintenance (of compilers and source code)
Readability vs. writability Perl is flexible and expressive—very writable As a result, Perl is sometimes hard to read... Writability vs. reliability C and C++ both provide flexible use of pointers As a result, C and C++ can be unreliably used ▪ Thus producing core dumps, null pointer references
Imperative Languages Data and programs are both stored in memory Variables mimic memory Assignment statements Arithmetic operations Iterative repetition Control structures etc.
1940s – von Neumann architecture 1950s – simple applications (hardware focus) 1960s/1970s – structured programming Costs shifted from hardware to software Complexity and size of software grew dramatically 1970s/1980s – data-oriented program design 1980s – object-oriented program design Data abstraction + Inheritance + Polymorphism 1990s/2000s – network/Web applications 2010s – mobile applications
Imperative languages: Evolved from the von Neumann architecture Focus on variables, assignment and arithmetic statements, control structures, and iterative constructs e.g. C, C++, Pascal, C#, Java, Perl, JavaScript, etc.
Functional languages: Apply (often recursive) functions to parameters Usually an interpretive language e.g. LISP, Scheme Logic languages: Rule-based approach to build a knowledge base Perform queries against knowledge base e.g. Prolog (also the Semantic Web)
Object-oriented languages: Evolved out of imperative languages Data abstraction, inheritance, polymorphism, late binding e.g. C++, Java, C#, Smalltalk, Eiffel Markup and Web languages: Web-based or application-specific markup languages specify layout of Web pages, database schemas, etc. e.g. XHTML, XML, XSLT, MathML, RDF, etc.
Low-level languages LDA #47 STA $570 DEX JSR $817 CPX #0 BNE #14 assembly code machine code (executable) translation program (assembler)
#include int main() { float x; cout << "... C++ source code intermediate code (object code) translation program (compiler) machine code (executable) linker program intermediate code of precompiled libraries ( object code)
public static void main( String[] args ) { float x; System.out. println( "... Java source code 7A F FE F D 4E intermediate code (byte code) translation program (compiler) virtual machine (JVM) A F AB AE F DA 44 intermediate code of precompiled libraries (java.util.Scanner byte code) program execution
lexical analysis groups characters into lexical units syntax analysis transforms lexical units into parse trees a parse tree represents the syntactic structure of the program analyzes parse trees to produce intermediate code transforms intermediate code into executable machine code
source code is both interpreted and executed via an interpreter REM COMMENT LET X = 5 LET Y = 8 PRINT X PRINT Y LET Z = X PRINT Z INPUT A$ BASIC source code
lexical analysis groups characters into lexical units syntax analysis transforms lexical units into parse trees analyzes parse trees to produce intermediate code intermediate code executed via a virtual machine
A preprocessor transforms source code into preprocessed source code Source program Preprocessor Preprocessed source program #include #define PI #define E #ifdef DEBUG_MODE #endif C source code
Read and study Chapters 1 and 2 Do Exercises at the end of Chapter 1 Categorize every programming language as compiled, interpreted, hybrid, etc.