1 The Evolution of Major Programming Languages Different Languages Characteristics.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter FourModern Programming Languages1 Language Systems.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Language Systems Chapter FourModern Programming Languages, 2nd ed.1.
High-Level Programming Languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
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.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
COP4020 Programming Languages
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Programming Languages Chapter OneModern Programming Languages, 2nd ed.1.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Introduction to High-Level Language Programming
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Language Systems Chapter FourModern Programming Languages 1.
CS 355 – Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
High-Level Programming Languages: C++
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Chapter 1 - Introduction
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
6/3/2016IT 3271 WhatHow A system (environment) for programmers to develops their programs in a certain programming language on a certain machine Chapter.
Chapter OneProgramming Languages1. Chapter OneProgramming Languages2 Recommended Course Textbooks A. B. Webber (2002) Modern Programming Languages: A.
Programming Language 1. Programming language A programming language is a machine-readable artificial language designed to express computations that can.
LANGUAGE SYSTEMS Chapter Four Modern Programming Languages 1.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Programming Languages
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
ISBN Structure of Programming Languages Prof. Dr. Mostafa Abdel Aziem Mostafa Senior Lecturer
Introduction to OOP CPS235: Introduction.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Programming Languages Chapter OneModern Programming Languages 1.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Chapter Goals Describe the application development process and the role of methodologies, models, and tools Compare and contrast programming language generations.
Advanced Computer Systems
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Visit for more Learning Resources
Concepts of Programming Languages
Chapter 1 Introduction.
PROGRAMMING LANGUAGES
Programming Languages
Compiler Construction (CS-636)
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
User-Defined Functions
COP4020 Programming Languages
Presentation transcript:

1 The Evolution of Major Programming Languages Different Languages Characteristics

2 Why have different languages? What makes programming languages an interesting subject? The amazing variety The odd controversies The intriguing evolution The connection to programming practice The many other connections

3 The Amazing Variety There are very many, very different languages (A list that used to be posted occasionally on comp.lang.misc had over 2300 published languages in 1995) Often grouped into four families: Imperative Functional Logic Object-oriented

4 Imperative Languages Example: a factorial function in C Characteristics of imperative languages: Assignment Iteration Order of execution is critical int fact(int n) { int sofar = 1; while (n>0) sofar *= n--; return sofar; }

5 Functional Languages Example: a factorial function in ML Characteristics of functional languages: Single-valued variables Heavy use of recursion fun fact x = if x <= 0 then 1 else x * fact(x-1);

6 Another Functional Language Example: a factorial function in Lisp Looks very different from ML But ML and Lisp are closely related Single-valued variables: no assignment Heavy use of recursion: no iteration (defun fact (x) (if (<= x 0) 1 (* x (fact (- x 1)))))

7 Logic Languages Example: a factorial function in Prolog Characteristics of logic languages Program expressed as rules in formal logic fact(X,1) :- X =:= 1. fact(X,Fact) :- X > 1, NewX is X - 1, fact(NewX,NF), Fact is X * NF.

8 Object-Oriented Languages Example: a Java definition for a kind of object that can store an integer and compute its factorial public class MyInt { private int value; public MyInt(int value) { this.value = value; } public int getValue() { return value; } public MyInt getFact() { return new MyInt(fact(value)); } private int fact(int n) { int sofar = 1; while (n > 1) sofar *= n--; return sofar; } }

9 Object-Oriented Languages Characteristics of object-oriented languages: Usually imperative, plus… Constructs to help programmers use “objects”—little bundles of data that know how to do things to themselves

10 Strengths and Weaknesses The different language groups show to advantage on different kinds of problems Decide for yourself at the end of the quarter, after experimenting with them Functional languages do well on functions Imperative languages, a bit less well Logic languages, considerably less well Object-oriented languages need larger examples

11 About Those Families There are many other language family terms Concurrent, Declarative, Definitional, Procedural, Scripting, Single-assignment, … Some languages straddle families Others are so unique that assigning them to a family is pointless

12 The Odd Controversies Programming languages are the subject of many heated debates: User arguments Language standards Fundamental definitions

13 User Arguments There is a lot of argument about the relative merits of different languages Every language has users, who praise it in extreme terms and defend it against all others To experience some of this, explore newsgroups: comp.lang.* (Plenty of rational discussion there too!)

14 New Languages A clean slate: no need to maintain compatibility with an existing body of code But never entirely new any more: always using ideas from earlier designs Some become widely used, others do not Whether widely used or not, they can serve as a source of ideas for the next generation

15 Widely Used: Java Quick rise to popularity since 1995 release Java uses many ideas from C++, plus some from Mesa, Modula, and other languages C++ uses most of C and extends it with ideas from Simula 67, Ada, ML and Algol 68 C was derived from B, which was derived from BCPL, which was derived from CPL, which was derived from Algol 60

16 Not Widely Used: Algol One of the earliest languages: Algol 58, Algol 60, Algol 68 Never widely used Introduced many ideas that were used in later languages, including Block structure and scope Recursive functions Parameter passing by value

17 The Connection To Programming Practice Languages influence programming practice A language favors a particular programming style—a particular approach to algorithmic problem-solving Programming experience influences language design

18 Language Influences Programming Practice Languages often strongly favor a particular style of programming Object-oriented languages: a style making heavy use of objects Functional languages: a style using many small side-effect-free functions Logic languages: a style using searches in a logically-defined problem space

19 Fighting the Language Languages favor a particular style, but do not force the programmer to follow it It is always possible to write in a style not favored by the language It is not usually a good idea…

20 Imperative ML fun fact n = let val i = ref 1; val xn = ref n in while !xn>1 do ( i := !i * !xn; xn := !xn - 1 ); !i end; ML makes it hard to use assignments, but it is still possible:

21 Non-object-oriented Java Java, more than C++, tries to encourage you to adopt an object-oriented mode. But you can still put your whole program into static methods of a single class: class Fubar { public static void main (String[] args) { // whole program here! }

22 Functional Pascal function ForLoop(Low, High: Integer): Boolean; begin if Low <= High then begin {for-loop body here} ForLoop := ForLoop(Low+1, High) end else ForLoop := True end; Any imperative language that supports recursion can be used as a functional language:

23 Programming Experience Influences Language Design Corrections to design problems make future dialects, as already noted Programming styles can emerge before there is a language that supports them Programming with objects predates object- oriented languages Automated theorem proving predates logic languages

24 Other Connections: Computer Architecture Language evolution drives and is driven by hardware evolution: Call-stack support – languages with recursion Parallel architectures – parallel languages Internet – Java

25 Other Connections: Theory of Formal Languages Theory of formal languages is a core mathematical area of computer science Regular grammars, lexical structure of programming languages, scanner in a compiler Context-free grammars, parser in a compiler

26 Language Systems

27 Language Systems The classical sequence Variations on the classical sequence Binding times Debuggers Runtime support

28 The Classical Sequence Integrated development environments are wonderful, but… Old-fashioned, un-integrated systems make the steps involved in running a program more clear We will look the classical sequence of steps involved in running a program (The example is generic: details vary from machine to machine)

29 Creating Remember from last lecture, the programmer uses an editor to create a text file containing the program A high-level language: machine independent This C-like example program calls fred 100 times, passing each i from 1 to 100: int i; void main() { for (i=1; i<=100; i++) fred(i); }

30 Compiling Compiler translates to assembly language Becomes Machine-specific Each line represents either a piece of data, or a single machine-level instruction Programs used to be written directly in assembly language, before Fortran (1957) Now used directly only when the compiler does not do what you want, which is rare

31 int i; void main() { for (i=1; i<=100; i++) fred(i); } i: data word 0 main: move 1 to i t1: compare i with 100 jump to t2 if greater push i call fred add 1 to i go to t1 t2: return compiler

32 Assembling Assembly language is still not directly executable Still text format, readable by people Still has names, not memory addresses Assembler converts each assembly-language instruction into the machine’s binary format: its machine language Resulting object file not readable by people

33 i: data word 0 main: move 1 to i t1: compare i with 100 jump to t2 if greater push i call fred add 1 to i go to t1 t2: return assembler

34 Linking Object file still not directly executable Missing some parts Still has some names Mostly machine language, but not entirely Linker collects and combines all the different parts In our example, fred was compiled separately, and may even have been written in a different high-level language Result is the executable file

35 linker

36 Loading “Executable” file still not directly executable Still has some names Mostly machine language, but not entirely Final step: when the program is run, the loader loads it into memory and replaces names with addresses

37 A Word About Memory For our example, we are assuming a very simple kind of memory architecture Memory organized as an array of bytes Index of each byte in this array is its address Before loading, language system does not know where in this array the program will be placed Loader finds an address for every piece and replaces names with addresses

38 Running After loading, the program is entirely machine language All names have been replaced with memory addresses Processor begins executing its instructions, and the program runs

39 The Classical Sequence

40 Variation: Hiding The Steps Many language systems make it possible to do the compile-assemble-link part with one command Example: gcc command on a Unix system: gcc main.cgcc main.c –S as main.s –o main.o ld … Compile, then assemble, then link Compile-assemble-link

41 Compiling to Object Code Many modern compilers incorporate all the functionality of an assembler They generate object code directly

42 Variation: Integrated Development Environments A single interface for editing, running and debugging programs Integration can add power at every step: Editor knows language syntax System may keep a database of source code and object code System may maintain versions, coordinate collaboration Rebuilding after incremental changes can be coordinated, like Unix make but language-specific

43 Variation: Interpreters To interpret a program is to carry out the steps it specifies, without first translating into a lower-level language Interpreters are usually much slower Compiling takes more time up front, but program runs at hardware speed Interpreting starts right away, but each step must be processed in software

44 Virtual Machines A language system can produce code in a machine language for which there is no hardware: an intermediate code Virtual machine must be simulated in software – interpreted, in fact Language system may do the whole classical sequence, but then interpret the resulting intermediate-code program

45 Why Virtual Machines Cross-platform execution Virtual machine can be implemented in software on many different platforms Simulating physical machines is harder Heightened security Running program is never directly in charge Interpreter can intervene if the program tries to do something it shouldn’t

46 The Java Virtual Machine Java languages systems usually compile to code for a virtual machine: the JVM JVM language is sometimes called bytecode Bytecode interpreter is part of almost every Web browser When you browse a page that contains a Java applet, the browser runs the applet by interpreting its bytecode

47 Intermediate Language Spectrum Pure interpreter Intermediate language = high-level language Tokenizing interpreter Intermediate language = token stream Intermediate-code compiler (Java) Intermediate language = virtual machine language Native-code compiler Intermediate language = physical machine language

48 Delayed Linking Delay linking step Code for library functions is not included in the executable file of the calling program

49 Delayed Linking: Windows Libraries of functions for delayed linking are stored in.dll files: dynamic-link library Two flavors Load-time dynamic linking Loader finds.dll files and links the program to functions it needs, just before running Run-time dynamic linking Running program makes explicit system calls to find.dll files and load specific functions

50 Delayed Linking: Unix Libraries of functions for delayed linking are stored in.so files: shared object Suffix.so followed by version number Two flavors Shared libraries Loader links the program to functions it needs before running Dynamically loaded libraries Running program makes explicit system calls to find library files and load specific functions

51 Delayed Linking: Java JVM automatically loads and links classes when a program uses them Class loader does a lot of work: May load across Internet Thoroughly checks loaded code to make sure it complies with JVM requirements

52 Delayed Linking Advantages Multiple programs can share a copy of library functions: one copy on disk and in memory Library functions can be updated independently of programs: all programs use repaired library code next time they run Can avoid loading code that is never used

53 Profiling The classical sequence runs twice First run of the program collects statistics: For example, parts most frequently executed Second compilation uses this information to help generate better code

54 Dynamic Compilation Some compiling takes place after the program starts running Many variations: Compile each function only when called Start by interpreting, compile only those pieces that are called frequently Compile roughly at first (for instance, to intermediate code); spend more time on frequently executed pieces (for instance, compile to native code and optimize) Just-in-time (JIT) compilation

55 Binding Binding means associating properties with an identifier from the program What set of values is associated with int ? What is the type of fred ? What is the address of the object code for main ? What is the value of i ? int i; void main() { for (i=1; i<=100; i++) fred(i); }

56 Binding Times Different bindings take place at different times There is a standard way of describing binding times with reference to the classical sequence: Language definition time Language implementation time Compile time Link time Load time Runtime

57 Language Definition Time Some properties are bound when the language is defined: Meanings of keywords: void, for, etc. int i; void main() { for (i=1; i<=100; i++) fred(i); }

58 Language Implementation Time Some properties are bound when the language system is written: range of values of type int in C implementation limitations: max identifier length, max number of array dimensions, etc int i; void main() { for (i=1; i<=100; i++) fred(i); }

59 Compile Time Some properties are bound when the program is compiled or prepared for interpretation: Types of variables, in languages like C and ML that use static typing Declaration that goes with a given use of a variable int i; void main() { for (i=1; i<=100; i++) fred(i); }

60 Link Time Some properties are bound when separately- compiled program parts are combined into one executable file by the linker: Object code for external function names int i; void main() { for (i=1; i<=100; i++) fred(i); }

61 Load Time Some properties are bound when the program is loaded into the computer’s memory, but before it runs: Memory locations for code for functions Memory locations for static variables int i; void main() { for (i=1; i<=100; i++) fred(i); }

62 Run Time Some properties are bound only when the code in question is executed: Values of variables Types of variables, in languages like Lisp that use dynamic typing Declaration that goes with a given use of a variable (in languages that use dynamic scoping) Also called late or dynamic binding

63 Late Binding, Early Binding The most important question about a binding time: late or early? Late: generally, this is more flexible at runtime (as with types & dynamic loading) Early: generally, this is faster and more secure at runtime (less to do, less that can go wrong) You can tell a lot about a language by looking at the binding times

64 Debugging Features Examine a snapshot, such as a core dump Examine a running program on the fly Single stepping, break-pointing, modifying variables Modify currently running program Recompile, re-link, reload parts while program runs Advanced debugging features require an integrated development environment

65 Debugging Information Where is it executing? What is the traceback of calls leading there? What are the values of variables? Source-level information from machine-level code Variables and functions by name Code locations by source position Connection between levels can be hard to maintain, for example because of optimization

66 Runtime Support Additional code the linker includes even if the program does not refer to it explicitly Startup processing: initializing the machine state Exception handling: reacting to exceptions Memory management: allocating memory, reusing it when the program is finished with it Operating system interface: communicating between running program and operating system for I/O, etc.

67 The End Read Chapter 3 – Describing Syntax and Semantics