<<

Overview

• Motivation • Why study programming languages? • Some key concepts Introduction

1 2

What is a ?

3 4 What is a programming language? On language and thought (1) “...there is no agreement on what a programming Idea: language effects thought language really is and what its main purpose is supposed to be. Is a programming language a “The Language of Thought Hypothesis (LOTH) tool for instructing machines? A means of communicating postulates that thought and thinking take place in a between ? A vehicle for expressing high-level mental language. This language consists of a system of designs? A notation for algorithms? A way of expressing representations that is physically realized in the brain of relationships between concepts? A tool for experimenta- thinkers and has a combinatorial syntax (and semantics) tion? A means of controlling computerized devices? My such that operations on representations are causally view is that a general-purpose programming language must sensitive only to the syntactic properties of be all of those to serve its diverse set of users. The only thing a language cannot be – and survive – is a mere representations. …” collection of ‘‘neat’’ features.” -- Stanford Encyclopedia of Philosophy -- http://plato.stanford.edu/entries/language-thought/ -- , The Design and Evolution of C++ http://www.cs.umbc.edu/331/papers/dne_notes.pdf Still controversial for natural languages: eskimos, numbers, etc. 5 6

On language and thought (2) On languages and thought (3)

The tools we use have a profound (and “What doesn't exist are really powerful devious!) influence on our thinking habits, general forms of arguing with computers right now. and therefore, on our thinking abilities. So we have to have special orders coming in on -- Edsger Dijkstra, How do we tell truths that might hurt?, special cases and then think up ways to do it. Some http://www.cs.umbc.edu/331/papers/ewd498.htm of these are generalizable and eventually you will get an actual engineering discipline.” Edsger Wybe Dijkstra (11 May 1930 -- 6 August 2002), http:// -- , Educom Review www.cs.utexas.edu/users/EWD/ Edsger Wybe Dijkstra, a noted pioneer of the science Alan Kay is one of the inventors of the programming and industry of computing, died after a long struggle with cancer language and one of the fathers of the idea of OOP. He is the on 6 August 2002 at his home in Neunen, the Netherlands. conceiver of the computer and the architect of the modern windowing GUI. l 7 8 Some General Underlying Issues Why study Programming • Why study PL concepts? Language Concepts? • Programming domains • Increased capacity to express programming • PL evaluation criteria concepts • Improved background for choosing appropriate • What influences PL design? languages • Tradeoffs faced by programming • Enhanced ability to learn new languages languages • Improved understanding of the significance of implementation • Implementation methods • Increased ability to design new languages • Programming environments • Mastering different programming paradigms

9 10

Programming Domains Language Evaluation Criteria

• Scientific applications • Readability • Business applications • Writability • Artificial intelligence • Reliability • Systems programming • Cost • Scripting languages • Special purpose languages • Etc…

11 12 Evaluation Criteria: Readability Evaluation Criteria: Writability • How easy is it to read and understand programs written in the PL? How easy is it to write programs in the • Arguably the most important criterion! language? • Factors effecting readability include: Factors effecting writability: – Overall simplicity – Simplicity and orthogonality » Too many features is bad as is a multiplicity of features – Support for abstraction – Orthogonality – Expressivity » Makes the language easy to learn and read – Fit for the domain and problem » Meaning is context independent – Control statements – Data type and structures – Syntax considerations 13 14

Evaluation Criteria: Reliability Evaluation Criteria: Cost Categories: Factors: – training - Type checking – creation - Exception handling – Compilation - Aliasing – Execution - Readability and writability – Compiler cost – Poor reliability – Maintenance

15 16 Evaluation Criteria: others Language Design Influences Computer architecture

• Portability - We use imperative languages, at least in part, • Generality because we use von Neumann machines - John von Neuman is generally considered to be • Well-definedness the inventor of the "stored program" machines, the • Good fit for hardware (e.g., cell) or class to which most of today's computers belong environment (e.g., Web) - CPU+memory which contains both program & data • etc… - Focus on moving data and program instructions between registers in CPU to memory locations

17 18

Von Neumann Architecture Language Design Influences: Programming methodologies

• 50s and early 60s: Simple applications; worry about machine efficiency • Late 60s: People efficiency became important; readability, better control structures. maintainability • Late 70s: Data abstraction • Middle 80s: Object-oriented programming • 90s: distributed programs, Internet, Web • 00s: cloud computing?, mobile/pervasive computing?, Web 2.0?, Web services?, virtual worlds?

19 20 Language Categories Language Design Trade-offs The big four: Reliability versus cost of execution Imperative or procedural (e.g., Fortran, C) Ada, unlike C, checks all array indices to ensure proper range. Functional (e.g., Lisp, ML) Writability versus readability Rule based (e.g. Prolog, Jess) (2 = 0 +.= T o.| T) / T <- iN Object-oriented (e.g. Smalltalk, Java) APL one-liner producing prime numbers from 1 Others: to N Scripting (e.g., Python, Perl, PHP, Ruby) Flexibility versus safety Constraint (e.g., Eclipse) C, unlike Java, allows one to do arithmetic Concurrent (Occam) on pointers. … 21 22

Implementation methods Compilation • Direct execution by hardware e.g., native machine language • Compilation to another language e.g., C compiled to native machine language for Intel Pentium 4 • Interpretation: direct execution by software e.g., csh, Lisp (traditionally), Python, JavaScript • Hybrid: compilation then interpretation Compilation to another language (aka bytecode), then interpreted by a ‘’, e.g., Java, Perl • Just-in-time compilation Dynamically compile some bytecode to native code (e.g., V8 javascript engine) 23 24 Interpretation Hybrid

25 26

Implementation issues Programming Environments 1. Complexity of compiler/interpreter • The collection of tools used in software development, often including an integrated editor, debugger, compiler, 2. Translation speed collaboration tool, etc. • Modern Integrated Development Environments (IDEs) 3. Execution speed tend to be language specific, allowing them to offer 4. Code portability support at the level at which the programmer thinks. • Examples: 5. Code compactness – UNIX -- Operating system with tool collection 1 – EMACS – a highly programmable text editor 6. Debugging ease 2 – Smalltalk -- A language processor/environment – Microsoft Visual C++ -- A large, complex visual environment 3 4 – Your favorite Java environment: BlueJ, Jbuilder, J++, … compile hybrid 5 interpret 6 – Generic: IBM’s Eclipse 27 28 Summary

• Programming languages have many aspects & uses • There are many reasons to study the concepts underlying programming languages • There are several criteria for evaluating PLs • Programming languages are constantly evolving • Classic techniques for executing PLs are compilation and interpretation, with variations

29