510 likes | 524 Views
Dive into the history, influences, and benefits of programming languages, including web and mobile applications, security, and big data. Learn about language goals, trade-offs, and evaluation criteria, enhancing your ability to express ideas and choose appropriate languages. Gain insights into various programming domains and implementation methods for a comprehensive understanding of modern programming languages.
E N D
Programming Language DesignChapter 1 CS 35000 Programming Language Design 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 • Better use of languages that are already known • Increased ability to learn new languages • Better understanding of significance of implementation • 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…. • Better understanding of languages’ runtime and implementation issues • Relative efficiency of alternative constructs • Common bugs
Reasons for Studying Programming Languages • Increased ability to learn new languages • Foundation for learning new languages • 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,“orthogonality is 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 • 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 • Ability to handle run-time errors • 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 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: 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 Neumann architecture • 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 Statements that 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/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?
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
Implementation Methods • Many languages have been implemented using both compilers and interpreters, including BASIC, C, Lisp, Pascal, and Python. • Java and C# are compiled into bytecode, the virtual machine-friendly interpreted language. (JVM) • Lisp implementations can freely mix interpreted and compiled code.
Implementation Methods What is the purpose of scripting language? • Ascript or scripting language is a computer language with a series of commands within a file that is capable of being executed without being compiled. • Good examples of server side scripting languages include Perl, PHP, and Python. • The best example of a client side scripting language is JavaScript..
Implementation Methods Why is a scripting language used? • Server-sidescripting languages that manipulate the data, usually in a database, on the server. • Scripting languages came about largely because of the development of the Internet as a communications tool. • JavaScript, ASP, JSP, PHP, Perl, Tcl and Python are examples of scripting languages.
Implementation Methods What is the difference between a scripting language and a programming language? • A scripting or script language is a programming language that supports scripts: • programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. • Scripting languages are often interpreted (rather than compiled).
Implementation Methods • Compilation • Programs are translated into machine language; includes JIT (Just-in-Time) systems Just-in-time compilation, a technique for improving the performance of virtual machines in computing. Just-in-Time Manufacturing, a business inventory strategy. • Use: Large commercial applications • Pure Interpretation • Programs are interpreted by another program known as an interpreter • Use: Small programs or when efficiency is not an issue • Hybrid Implementation Systems • A compromise between compilers and pure interpreters • Use: Small and medium systems when efficiency is not the first concern
Implementation Methods: Compilation Source Code • Translates a high-level program to machine code • Features: • Slow translation • Fast execution • Separate compiled units must be combined by a linker into an executable (.exe file) Compiler Lexical Analyzer Intermediate Code Syntax Analyzer Semantic Analyzer Code Generator Machine Code Input data Computer
Implementation Methods: Pure Interpretation Source Code • An interpreter is a computer program that directly executes (performs) instructions written in a programming or scription languages, without previously compiling them into a machine program. Input data Interpreter Machine Code Computer
Implementation Methods: Pure Interpretation Source Code • No translation before execution • Features: • Slow execution • Loop statements are repeatedly translated • Some web scripting languages still prefer pure interpretation: • JavaScript • PHP • Why? Input data Interpreter Machine Code Computer
Implementation Methods: Hybrid Implementation Systems Source Code Compiler • Translates a high-level language to intermediate code, and then interpret it • The Intermediate code is called bytecode • The Java interpreter is the JVM later on • Each statement is translated only once in contrast to pure interpretation • Medium execution speed • Just-In-Time (JIT) technology now widely used with Java and .NET Lexical Analyzer Syntax Analyzer Intermediate Code Generator Intermediate Code (bytecode) Interpreter Input data Machine Code Computer
Programming Environments • The collection of tools used in software development, which AKA integrated development environment (IDE) [aka: also know as] • File system, text editor, compiler, linker • Eclipse/Netbeans • An integrated development environment for Java and other languages • Microsoft Visual Studio.NET • A large, complex visual environment • Used to build Web applications and non-Web applications in any .NET language • Used to program in C#, Visual BASIC.NET, Jscript, J#, and C++