Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3370: Principles of Programming Languages Introduction

Similar presentations


Presentation on theme: "CSCI 3370: Principles of Programming Languages Introduction"— Presentation transcript:

1 CSCI 3370: Principles of Programming Languages Introduction
Dr. Vamsi Paruchuri University of Central Arkansas These slides are available at:

2 What is a Programming Language?
Definition: A programming language is a notational system for describing computation in machine-readable and human-readable form.

3 At the beginning, there was no programming languages…
Machine code example: 1st column: memory address 2nd column: machine code in hex format

4 A question What’s the best car? What are the best shoes?

5 An answer Of course it depends on what you are doing
Programming languages have many goals, including making it easy in your domain to: Write correct code Write fast code Write large projects Interoperate

6 Another question Aren’t all cars the same?
“4 wheels, a steering wheel, a brake – the rest is unimportant details” - YES - NO!! Standards help (easy to build roads and rent a car) But legacy issues dominate (why are cars/roads the width they are?)

7 Aren’t all PLs the same? Almost every language is the same
Yes: Certain fundamentals appear almost everywhere (variables, abstraction, records, recursive definitions) No: Real differences at formal and informal levels TIOBE Programming Community Index:

8 Why? Increased capacity to express ideas
Improved background for choosing appropriate languages Increased ability to learn new languages Better understanding of the significance of implementation

9 Programming Domains Scientific Applications Business Applications
Fortran Business Applications COBOL Artificial Intelligence LISP, Prolog, Scheme Systems Programming ALGOL Web Programming JavaScript, PHP

10 Language Evaluation Criteria
Readability The most important criterion Factors: Overall simplicity Too many features is bad Multiplicity of features is bad (e.g., a++, ++a) Operator Overloading Orthogonality Makes the language easy to learn and read Meaning is context independent A relatively small set of primitive constructs can be combined in a relatively small number of ways Every possible combination is legal Lack of orthogonality leads to exceptions to rules

11 Language Evaluation Criteria
Readability factors (continued) Control statements goto Vs loops Defining data types and structures (e.g., Boolean variables) Syntax considerations Identifier forms and lengths Special words Form and meaning grep !?

12 Language Evaluation Criteria
Writability Factors: Simplicity and orthogonality Support for abstraction (Process and Data) Expressivity (eg., count++ Vs. count = count+1) Reliability Type checking Exception handling Aliasing Readability and writability

13 Language Evaluation Criteria
Cost Categories Training programmers to use language Writing programs Compiling programs Executing programs Optimization Language implementation system Reliability Maintaining programs Others: portability, generality, well- definedness

14 Picking a language Admittedly, semantics can be far down the priority list: What libraries are available? What do management, clients want? What is the de facto industry standard? What does my team already know? But: Nice thing about class: we get to ignore all that Technology leaders affect the answers Sound reasoning about programs requires semantics Mission-critical code doesn’t “seem to be right” Blame: the compiler vendor or you?

15 Von Neumann Architecture
We use imperative languages, at least in part, because we use von Neumann machines Data and programs stored in same 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 Because instructions are stored in adjacent cells

16 Von Neumann Architecture

17 Von Neumann Architecture
Stored-program computer in which an instruction fetch and a data operation cannot occur at the same time because they share a common bus. This is referred to as the Von Neumann bottleneck and often limits the performance of the system. On a large scale, the ability to treat instructions as data is what makes assemblers, compilers and other automated programming tools possible. A stored-program design also allows for self- modifying code.

18 Von Neumann bottleneck
The shared bus between the program memory and data memory leads to the limited throughput (data transfer rate) between the CPU and memory compared to the amount of memory. Because program memory and data memory cannot be accessed at same time, throughput is much smaller than rate at which the CPU can work. This seriously limits the effective processing speed when the CPU is required to perform minimal processing on large amounts of data. The CPU is continually forced to wait for needed data to be transferred to or from memory.

19 Influences on Language Design
Programming methodologies 1950s and early 1960s: Simple applications; worry about machine efficiency Late 1960s: People efficiency became important; readability, better control structures Structured programming Top-down design and step-wise refinement Late 1970s: Process-oriented to data-oriented data abstraction Middle 1980s: Object-oriented programming

20 Language Design Trade-Offs
Reliability vs. cost of execution Array bounds Readability vs. writability Flexibility vs. safety Pointers

21 Layered View of Computer

22 Language translation Compiler: two-step process that translates source code into target code; then the user executes the target code. Interpreter: one-step process in which the source code is executed directly. Hybrids are also possible (Java, C#).

23 Compilation Process Translate high-level program to machine code - Slow translation - Fast execution

24 Implementation Methods
Pure interpretation No translation Slow execution Becoming rare E.g., JavaScript, PHP

25 Implementation Methods
Hybrid implementation systems Small translation cost Medium execution speed E.g., Perl, Java JIT

26 Programming Environments
The collection of tools used in software development UNIX An older operating system and tool collection Borland JBuilder An integrated development environment for Java Microsoft Visual Studio.NET A large, complex visual environment Used to program in C#, Visual BASIC.NET, Jscript, J#, or C++

27 Language definition Syntax: How to write the structure of a program.
Usually given a formal (i.e., mathematical) definition using a context-free language. (Lexical structure - the structure of the words or tokens - uses regular expressions.) Semantics: What does it mean the actual result of execution. Usually described in English, but can be done mathematically. Semantics can have a static component: type checking, definition checking, other consistency checks prior to execution and a dynamic component.

28 Summary Language description consists of Syntax Specification and a Semantics Specification. Syntax describes what programs look like; Semantics describes what they mean.


Download ppt "CSCI 3370: Principles of Programming Languages Introduction"

Similar presentations


Ads by Google