580 likes | 591 Views
Programming Language Design Chapter 1. CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne. Value of Language Concepts. History and Now Began programming in 1990’s Dominant languages were Pascal, C, and C++
E N D
Programming Language DesignChapter 1 CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne
Value of Language Concepts • History and Now • Began programming in 1990’s • Dominant languages were Pascal, C, and C++ • Most of the languages were designed to running on a single machine • Today: Most of the popular language have to considered their availability for • Web application • Mobile application/Cloud computing • Service-oriented environment • Security • Big Data
Language goals and Its Role Architect Programmer Programming Language Testing Compiler, Runtime environ-ment DiagnosticTools
Outlines • Reasons for Studying Concepts of Programming Languages • Programming Domains • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Methods • Programming Environments
Reasons for Studying Concepts of Programming Languages • Increased ability to express ideas • Improved background for choosing appropriate languages • Increased ability to learn new languages • Better understanding of significance of implementation • Better use of languages that are already known • Overall advancement of computing
Reasons for Studying Concepts of Programming Languages • Increased ability to express ideas • The expressive power of the language • influences the depth at which we can think • Easy to conceptualize structures of ideas • An Example : implementing a complex application using assembly language • Without the concept of object-oriented programming
Reasons for Studying Programming Languages • Improve ability for choosing appropriate languages • Be Familiar with languages’ features…. • Increased ability to learn new languages • Foundation for learning new languages
Reasons for Studying Programming Languages • Better understanding of languages’ runtime and implementation issues • Relative efficiency of alternative constructs • Common bugs • Proper use of languages that are already known • Overall advancement of computing
Programming Domains • Scientific applications • Large numbers of floating point computations; use of arrays • Fortran • Business applications • Produce reports, use decimal numbers and characters • COBOL • Artificial intelligence • Symbols rather than numbers manipulated; use of linked lists • LISP • Systems programming • Need efficiency because of continuous use • C • Web Software • Eclectic collection of languages: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) • Mobile Computing • Object C/J2ME
Programming Domains • Web Applications • Markup languages • HTML/XHTML • Scripting languages • Shell, Perl, JavaScript, PHP, Ruby, Lua, Python • Mobile Computing • Object C/J2ME
Programming Domains • Scientific applications • Large number of floating point computations • Use of arrays • Examples: Matlab, R, Mathematica, Fortran • Business applications • Produce software and reports • Use decimal numbers and characters • Examples: COBOL, SQL, Java, C#, .NET
Programming Domains • Artificial intelligence • Require to manipulate symbols, rather than numbers • Use of linked lists • Examples: LISP and Prolog • Systems programming • Need for efficiency and high performance • Need to access low-level device drivers and the kernel of Operating System • Examples: C/C++
Outline • Reasons for Studying Concepts of Programming Languages • Programming Domains • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Methods • Programming Environments
Language Evaluation Criteria • Readability • Programs can be read and understand at ease • Writability • A language can be used at east to create programs • Reliability and Security • Performs to its specifications (Conformance) • Cost • The ultimate total cost • Other -- portability, generality, well-definition
Language Evaluation Criteria: Cost • Maintenance cost of a software can be 70 – 90% of system life-cycle cost
Language Evaluation Criteria: Readability • Overall simplicity • A manageable set of features and constructs • Minimal feature multiplicity • Minimal operator overloading • Orthogonality • A relatively small set of primitive constructs can be combined in a relatively small number of ways • Every possible combination is legal • Data types • Adequate predefined data types • Syntax considerations • Identifier forms: flexible composition • Special words and methods of forming compound statements • Form and meaning: self-descriptive constructs, meaningful keywords Java I/O API : http://docs.oracle.com/javase/1.4.2/docs/api/java/io/package-summary.html
Language Evaluation Criteria: Readability • Overall simplicity • Too many features are bad Reader of a program may not familiar with the subset of the language, which used by the programmer • Multiplicity of features is bad – 1+ way to accomplish the same task Are you confused by Java I/O choices? • Operator overloading is bad one operator has 1+ meaning(s) Java I/O API : http://docs.oracle.com/javase/1.4.2/docs/api/java/io/package-summary.html
Language Evaluation Criteria: Readability • Orthogonality is an important guideline of designing a language with good Readability In mathematics,“orthogonalityis the relation of two lines at right angles to one another (perpendicularity), and the generalization of this relation into n dimensions; it has been used to describe non-overlapping, uncorrelated, or independent objects of some kind. “--- Wiki It means non-redundant, non-overlapping or irrelevant. The characteristic of something being independent from something else. The line segments AB and CD are orthogonal to each other.
Language Evaluation Criteria: Readability • Orthogonality context independent • Combine a relatively small set of primitive constructs in a relatively small number of ways to get the desired results • Consistent set of rules for combining constructs (simplicity) • Makes a language easy to read and learn A PL is orthogonal if its features can be used without thinking about how that usage will affect other features.
Orthogonality Example • Example: in C you can't return an array(static array), C is said to be non-orthogonal in this case int * func( ) { …} //return a array from a function //by declaring a func returning a pointer. //define the local variable as static //variable, for C does not advocate to //return the address of a local variable to //outside the function.
Language Evaluation Criteria: Readability Readability also refers to the following characteristics: • Convenient control statements • Ability to define different data types and structures • Syntax considerations • Meaningful reserved words The meaning those words should be straightforward
Language Evaluation Criteria: Writability Most readability factors also apply to writability • Simplicity and orthogonality • Few constructs, a small number of primitives, a small set of rules for combining them • Support for abstraction • The ability to define and use complex structures or operations in ways that allow details to be ignored • Expressivity • A set of relatively convenient ways of specifying operations • Strength and number of operators and predefined functions
Language Evaluation Criteria: Writability Most readability factors also apply to writability • Overly simplicity and orthogonality • Few constructs, a small number of primitives, a small set of rules for combining them • Control statements, data types and structures • Support for abstraction • The ability to define and use complex structures or operations in ways that allow details to be ignored • the ability express complicated data and procedure • Data abstraction • Process abstraction • Expressivity
Language Evaluation Criteria: Writability Most readability factors also apply to writability • Overly simplicity and orthogonality • Support for abstraction • Expressivity • A set of relatively convenient ways of specifying operations • Convenient way to specify computation. From writability’s perspective: • Count++ is better than Count=Count+1 • Strength and number of operators and predefined functions
Evaluation Criteria: Reliability • Type checking • Testing for type errors • Exception handling • Intercept run-time errors and take corrective measures • Aliasing • Presence of two or more distinct referencing methods for the same memory location • Readability and writability • A language that does not support “natural” ways of expressing an algorithm will require the use of “unnatural” approaches, and hence reduced reliability
Evaluation Criteria: Reliability Readability and writability both influence: reliability and security • Type checking • Testing for type errors • Exception handling • Ability to handle run-time errors • Intercept run-time errors and take corrective measures • Aliasing • Ability to use different names to reference the same memory • It might become a dangerous feature!
Evaluation Criteria: Cost and Others • Cost • Purchasing license • Training programmers to use a language • Writing programs in a particular problem domain • Compiling and Executing programs • Reliability: poor reliability leads to high costs • Maintaining programs • Others: portability, generality, well-definition
Evaluation Criteria: Cost • Training programmers to use the language • Writing programs (closeness to particular applications) • Compiling programs • Executing programs • Language implementation system: availability of free compilers • Reliability: poor reliability leads to high costs • Maintaining programs
Evaluation Criteria: Others • Portability • Move programs from one implementation to another at ease • Generality • The applicability to a wide range of applications • Well-definedness • The completeness and precision of the language’s official definition
Reasons for Studying Concepts of Programming Languages • Increased ability to express ideas • Improved abilityfor choosing appropriate languages • Increased ability to learn new languages • Better understanding of languages’ significance of implementation • Properuse of languages that are already known • Overall advancement of computing
Programming Domains • Scientific applications • Large numbers of floating point computations; use of arrays • Fortran • Business applications • Produce reports, use decimal numbers and characters • COBOL • Artificial intelligence • Symbols rather than numbers manipulated; use of linked lists • LISP • Systems programming • Need efficiency because of continuous use • C • Web Software • Eclectic collection of languages: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) • Mobile Computing • Object C/J2ME
Language Evaluation Criteria • Readability • Programs can be read and understand at ease • Writability • A language can be used at ease to create programs • Reliability and Security • Performs to its specifications (Conformance) • Cost • The ultimate total cost • Other -- portability, generality, well-definition
Language Evaluation Criteria: Readability • Overall simplicity • A manageable set of features and constructs • Minimal feature multiplicity • Minimal operator overloading • Orthogonality • A relatively small set of primitive constructs can be combined in a relatively small number of ways • Every possible combination is legal • Data types • Adequate predefined data types • Syntax considerations • Identifier forms: flexible composition • Special words and methods of forming compound statements • Form and meaning: self-descriptive constructs, meaningful keywords Java I/O API : http://docs.oracle.com/javase/1.4.2/docs/api/java/io/package-summary.html
Language Evaluation Criteria: Writability Most readability factors also apply to writability • Simplicity and orthogonality • Few constructs, a small number of primitives, a small set of rules for combining them • Support for abstraction • The ability to define and use complex structures or operations in ways that allow details to be ignored • Expressivity • A set of relatively convenient ways of specifying operations • Strength and number of operators and predefined functions
Evaluation Criteria: Reliability • Type checking • Testing for type errors • Exception handling • Intercept run-time errors and take corrective measures • Aliasing • Presence of two or more distinct referencing methods for the same memory location • Readability and writability • A language that does not support “natural” ways of expressing an algorithm will require the use of “unnatural” approaches, and hence reduced reliability
Evaluation Criteria: Cost • Training programmers to use the language • Writing programs (closeness to particular applications) • Compiling programs • Executing programs • Language implementation system: availability of free compilers • Reliability: poor reliability leads to high costs • Maintaining programs
Evaluation Criteria: Others • Portability • Move programs from one implementation to another at ease • Generality • The applicability to a wide range of applications • Well-definedness • The completeness and precision of the language’s official definition
Outlines • Reasons for Studying Concepts of Programming Languages • Programming Domains • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Methods • Programming Environments
Influences on Language Design • What factors shapesthe current specifications of programming languages? • The advance of computer hardware • Programming methodologies influences
The Advance Of Computer Hardware Store instructions and data • Von Neumann Computer Architecture • The first draft of Modern computer (1945) • Still used today • Features: • Data and programs stored in same memory • Memory is separate from CPU • Instructions and data are piped from memory to CPU Request of operations Instructions and data CPU
Influences on Language Design • The Advance Of Computer Hardware Computer Architecture • Languages are developed around the prevalent computer architecture, known as the von Neumannarchitecture • Imperative languages, most dominant, because of von Neumann computers • Data and programs stored in memory • Memory is separate from CPU • Instructions and data are piped from memory to CPU • Basis for imperative languages • Variables model memory cells • Assignment statements model piping • Iteration is efficient
Influences on Language Design • Based on the Von Neumann Architecture, the modern programming languages must be designed as imperative languages, whose key features are: • Use Statementsthat change a program state • Use Variables to model memory cells • Use Assignment statements to model piping • Use Iteration to implement repetition • Use Condition Statement to implement decision-making
The Historic ReasonsProgramming Methodologies Influences • Programming methodologies changes • 1950s and early 1960s • Simple applications • Primarily concern about machine efficiency • Late 1960s • “People efficiency” became important • Readability • Better control structures • Structured programming • Top-downdesign and step-wise refinement
The Historic ReasonsProgramming Methodologies Influences • Programming methodologies changes • Late 1970s • Process-oriented techniques yielded to data-oriented techniques • Data abstraction • Middle 1980s to present • Object-oriented languages • Encapsulation with data abstraction • Inheritance • polymorphism • Dynamic method binding • Smalltalk (1980) and Java (1995) • Concurrent and parallel languages • Creating and controlling concurrent program units
Outline • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Methods • Programming Environments • Language Implementation Issues
Language Categories • Imperative • Central features are variables, assignment statements, and iteration • Include languages that support object-oriented programming • Include scripting languages • Include the visual languages • Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++ • Functional • …
Language Categories • Imperative • Functional • Main means of making computations is by applying functions to given parameters • Examples: LISP, Scheme, ML, F# • Logic • Rule-based (rules are specified in no particular order) • Example: Prolog • Markup/programming hybrid • Markup languages extended to support some programming • Examples: JSTL, XSLT
Language Design Trade-Offs • Reliability vs. cost of execution • Example: Java demands all references to array elements be checked for proper indexing, which leads to increased execution costs • Readability vs. writability Example: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poorreadability • Writability (flexibility) vs. reliability • Example: C++ pointers are powerful and very flexible but are unreliable
Language Design Trade-Offs • Designing a programming language involves numerous compromises and trade-offs. For example, • Writabilityv.s. Reliability • Pascal variant records are flexible but not safe • C++ pointers are flexible but not safe • Reliability v.s. Efficiency • Range checking for array references?