Cs784(Prasad)L1Intro1 Systematic Development of Programming Languages.

Slides:



Advertisements
Similar presentations
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Advertisements

Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Chapter One Preliminaries, including –Why study PL concepts? –Programming domains –PL evaluation criteria.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 1: Preliminaries
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
Mark Hennessy CS351 Dept. Computer Science NUIM CS 351 Introduction.
High-Level Programming Languages
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
CS 354 Overview. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Course Topics What is a programming language? What features do programming.
The Evolution of Programming Languages
Programming Languages Structure
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Presented by Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Programming Language Concepts
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
CS 355 – Programming Languages
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
CIS Computer Programming Logic
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Chapter 1. Introduction.
CS 363 Comparative Programming Languages
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
1 CSC 533: Organization of Programming Languages Spring 2010 See online syllabus at: Course goals:  understand issues in designing,
1 Programming Language History and Evolution In Text: Chapter 2.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
ISBN CS 354 Preliminaries. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Course Topics What is a programming language? What features.
ISBN Chapter 1 Preliminaries. Copyright © 2009 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of.
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05.
Cs3180 (Prasad)LSysVsScipt1 Scripting vs Systems Programming Languages u Designed for gluing applications : flexibility u Interpreted u Dynamic variable.
Programming Languages
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Programming Languages
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
History. Development Driven by Function Functions of a Programming Language –To describe computation for use by computers –To describe computation and.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Programming Language History and Evolution
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Programming Languages 2nd edition Tucker and Noonan
Type Checking and Type Inference
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Concepts of Programming Languages
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Why study programming languages?
PROGRAMMING LANGUAGES
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
课程名 编译原理 Compiling Techniques
Programming Language History and Evolution
Evolution of programming languages
Programming Language Design
Programming Languages 2nd edition Tucker and Noonan
Principles of Programming Languages
Programming Languages and Paradigms
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Programming Languages, Preliminaries, History & Evolution
Presentation transcript:

cs784(Prasad)L1Intro1 Systematic Development of Programming Languages

cs784(Prasad)L1Intro2 Orthogonal Parameters u Conceptual view ( Model of Computation ) »imperative, functional, relational,... u Level of abstraction ( Model of Implementation ) »problem domain »... »machine –Computational Task : I/O relation to be implemented

cs784(Prasad)L1Intro3 1. Customized Digital Computer Oj Ij Ik Ok Task j Task k Rig different circuit for each task

cs784(Prasad)L1Intro4 u von Neumann showed the existence of a Universal Machine (hardware) that can be customized using control inputs to carry out different tasks. u Software is the encoding of the task to control this machine. 2. Stored Program Computing encoding(Tj) IjOj

cs784(Prasad)L1Intro5 Imperative Languages u Model of Computation »ALU + Memory + Input + Output (von Neumann architecture) u Levels of Abstraction (“ Human Interface ”) –Machine Language »Binary Representation of the task –Assembly Language »Symbolic Representation of the task

Assembly Language u Use symbols instead of binary digits to describe fields of instructions. u Every aspect of machine visible in program: –One statement per machine instruction. –Register allocation, call stack, etc. must be managed explicitly.  No structure: everything looks the same ADDIR4R221 ADDI R4,R2,21

cs784(Prasad)L1Intro7 Pros and Cons of Assembly Language u Avoids Absolute Addressing »relocatable, reusable/shareable u Uses Symbolic Names »readable  Low-level programming wastes effort in coding a solution rather than solving a problem. u Difficult to build and maintain large programs.

cs784(Prasad)L1Intro8 High-level Language u Provides notation to describe problem solving strategies rather than organize data and instructions at machine-level.  Improves programmer productivity by supporting features to abstract/reuse code, and to improve reliability/robustness of programs. u Requires a compiler.

cs784(Prasad)L1Intro9 Levels of Abstraction Problem Domain (stacks, tables) Machine (char, int) C++ (Class Hierarchies) Java/C#/Scala/Python/Scheme Ada C Pascal Assembly Language (ADTs) (arrays)

cs784(Prasad)L1Intro10 Evolution of Programming Languages FORTRAN ( FORmula TRANslator) Goals : Scientific Computations Efficiency of execution Compile-time storage determination Features : Symbolic Expressions Subprograms Absence of Recursion COBOL Goal: Business Application Features : Record/Structure; File Handling

cs784(Prasad)L1Intro11 Evolution of Programming Languages ALGOL - 60 (ALGOrithmic Language) Goals : Communicating Algorithms Features : Block Structure (Top-down design) Recursion (Problem-solving strategy) BNF - Specification LISP (LISt Processing) Goals : Manipulating symbolic information Features : List Primitives Interpreters / Environment

cs784(Prasad)L1Intro12 Problems u Not rugged wrt typographical errors Do 10 I = 1.20 I5 = I5 + 1 vs vs Do 10 I = 1,20 I5 = IK + 1 –Remedy: Declare before use u Unintended Coercion I > J and false –Remedy: Type checking

cs784(Prasad)L1Intro13 Evolution of Programming Languages Pascal Goal : Structured Programming, Type checking, Compiler writing. Features : Rich set of data types for efficient algorithm design E.g., Records, sets,... Variety of “readable” single-entry single-exit control structures E.g., for-loop, while-loop,... Efficient Implementation Recursive descent parsing

cs784(Prasad)L1Intro14 Programming in the Large u Programs no longer monolithic. Developed by a team of programmers. u Code sharing and reuse very important. u Correctness, reliability, and robustness essential. –Data Abstraction / Encapsulation / Strong Typing »Ada, CLU, Modula etc.

cs784(Prasad)L1Intro15 Other Languages u Functional »Common LISP, Scheme »ML, Haskell u Logic »Prolog u Object-oriented »Smalltalk, SIMULA, Modula-3, Oberon »C++, Java, C#, Eiffel, Ada-95 u Hybrid »Python, Ruby, Scala u Application specific languages and tools

cs784(Prasad)L1Intro16 Scripting vs Systems Programming Languages u Designed for gluing applications : flexibility u Interpreted u Dynamic typing and variable creation u Data and code integrated : meta-programming supported u Examples: PERL, Tcl, Python, Ruby, PHP, Scheme, Visual Basic, Scala, etc. u Designed for building applications : efficiency u Compiled u Static typing and variable declaration u Data and code separated : cannot create/run code on the fly u Examples: PL/1, Ada, Java, C, C++, C#, Scala, etc.

cs784(Prasad)L1Intro17 (cont’d) u Does application implement complex algorithms and data structures? u Does application process large data sets (>10,000 items)? u Are application functions well-defined, fixed? If yes, consider a system programming language. u Is the main task to connect components, legacy apps? u Does the application manipulate a variety of things? u Does the application have a GUI? u Are the application's functions evolving rapidly? u Must the application be extensible? u Does the application do a lot of string manipulation? If yes, consider a scripting language.

cs784(Prasad)L1Intro18 Jython (for convenient access to Java APIs) I:\tkprasad\cs784>jython Jython 2.1 on java1.4.1_02 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import javax.swing as swing >>> win = swing.JFrame("Welcome to Jython") >>> win.size = (200, 200) >>> win.show() >>> ^Z

cs784(Prasad)L1Intro19 Java vs Jython map = new HashMap(); map.put("one",new Integer(1)); map.put("two",new Integer(2)); map.put("three",new Integer(3)); System.out.println(map.get("one")); list = new LinkedList(); list.add(new Integer(1)); list.add(new Integer(2)); list.add(new Integer(3)); map = {"one":1,"two":2,"three":3} print map ["one"] list = [1, 2, 3]

cs784(Prasad)L1Intro20 (cont’d) for i in list: (* iterator *) newList = [function(i) for i in oldList] (* list comprehension *) for (Iterator i; i.hasNext();) { i.next(); } List newList = ArrayList() for (Iterator i; i.hasNext();) { Object obj = i.next(); newList.add(function(obj)) }

cs784(Prasad)L1Intro21 Functional Programming in Jython apply(lambda x,y : x*y, (10, 20)) # 200 map(lambda x,y: x + y, [[1,2],[“a”]], [[“3”],[“b”]]) # [[1, 2, ‘3’], [‘a’, ‘b’]] reduce(lambda x,y: x + y, [1,2,3], 100) # 106 filter(lambda x: x > 0, range(10,-5,-3)) # [10, 7, 4, 1]

cs784(Prasad)L1Intro22 Meta-programming in Jython u Dynamic code evaluation print eval (“[1,3] + range(6,10,3)”) # [1,,3, 6, 9] x = 2 + 3j exec “x = 5, x + x” #(5, (4+6j)

cs784(Prasad)L1Intro23 import java.lang as lang import javax.swing as swing import java.awt as awt names = ["Groucho", "Chico", "Harpo"] quotes = {"Groucho": "Say the secret word", "Chico": "Viaduct?", "Harpo": "HONK!"} def buttonPressed(event): field.text = quotes[event.source.text] def exit(event): lang.System.exit(0) def createButton(name): return swing.JButton(name, preferredSize=(100,20), actionPerformed=buttonPressed) Java functionality through Jython

cs784(Prasad)L1Intro24 win = swing.JFrame("Welcome to Jython", size=(200, 200),windowClosing=exit) win.contentPane.layout = awt.FlowLayout( ) field = swing.JTextField(preferredSize=(200,20)) win.contentPane.add(field) buttons = [createButton(each) for each in names] for eachButton in buttons: win.contentPane.add(eachButton) win.pack( ) win.show( )

Current Trend u Multiparadigm languages –Functional constructs for programming in the small »Focus on conciseness and correctness –Object-Oriented constructs for programming in the large »Focus on programmer productivity and code evolution u Example languages –Older: Python, Ruby, –Recent: Scala, F#, etc cs784(Prasad)L1Intro25

cs784(Prasad)L1Intro26 Scheme (dialect of LISP) u Recursive definitions u Symbolic computation : List Processing u Higher-order functions u Dynamic type checking u Functional + Imperative features u Automatic storage management –Provides a uniform executable platform for studying, specifying, and comparing languages.

cs784(Prasad)L1Intro27 Standard ML and Scala u Strongly typed language –static type inference –SML supports polymorphic types u Supports Abstract Data Types and Modules u Higher-order functions u Pattern matching –cf. Prolog, list-processing in Scheme

Java vs Scala //Java - what we're used to seeing public String buildEpochKey(String... keys) { StringBuilder s = new StringBuilder("elem") for(String key:keys) { if(key != null) { s.append(".") s.append(key) } return s.toString(). toLowerCase() } cs784(Prasad)L1Intro28

Java vs Scala //Scala def buildEpochKey(keys: String*): String = { ("elem" +: keys) filter(_ != null) mkString(".") toLowerCase } cs784(Prasad)L1Intro29