Similar documents
Chapter 5. Names, Bindings, and Scopes

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Chapter 5 Names, Binding, Type Checking and Scopes

Programming Languages, Summary CSC419; Odelia Schwartz

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Principles of Programming Languages. Lecture Outline

Topic 9: Type Checking

Topic 9: Type Checking

Chapter 5 Names, Bindings, Type Checking, and Scopes

Type Checking and Type Equality

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Concepts of Programming Languages

Lecture 4 Memory Management

CMSC 330: Organization of Programming Languages

Final-Term Papers Solved MCQS with Reference

Type Bindings. Static Type Binding

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

Concepts of Programming Languages

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

CS 3360 Design and Implementation of Programming Languages. Exam 1

Language Evaluation P L COS 301. Fall School of Computing and Information Science University of Maine. Language Evaluation COS 301.

Semantic Analysis. How to Ensure Type-Safety. What Are Types? Static vs. Dynamic Typing. Type Checking. Last time: CS412/CS413

Chapter 1. Preliminaries

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

CSCI-GA Scripting Languages

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Programming Languages Third Edition. Chapter 7 Basic Semantics

CS 3360 Design and Implementation of Programming Languages. Exam 1

Chapter 5. Variables. Topics. Imperative Paradigm. Von Neumann Architecture

Pointers (continued), arrays and strings

The role of semantic analysis in a compiler

Pointers (continued), arrays and strings

Chapter 7. Expressions and Assignment Statements ISBN

Software II: Principles of Programming Languages. Why Expressions?

Semantic Analysis. Lecture 9. February 7, 2018

NOTE: Answer ANY FOUR of the following 6 sections:

New Programming Paradigms

Chapter 7. Expressions and Assignment Statements

Chapter 1. Preliminaries

Chapter 1 Preliminaries

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

Project Compiler. CS031 TA Help Session November 28, 2011

CIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL

CS201 - Introduction to Programming Glossary By

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

Data Types (cont.) Administrative Issues. Academic Dishonesty. How do we detect plagiarism? Strongly Typed Languages. Type System

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Chapter 7. Expressions and Assignment Statements (updated edition 11) ISBN

Chapter 9 Subprograms

CSc 520. Principles of Programming Languages 25: Types Introduction

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 17: Types and Type-Checking 25 Feb 08

Answer: Early binding generally leads to greater efficiency (compilation approach) Late binding general leads to greater flexibility

Reversing. Time to get with the program

Introduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages

Chapter 7. Expressions and Assignment Statements

Types. What is a type?

CSCE 314 Programming Languages. Type System

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow

Imperative Programming

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

From the λ-calculus to Functional Programming Drew McDermott Posted

Simply-Typed Lambda Calculus

More Lambda Calculus and Intro to Type Systems

Chapter 6 part 1. Data Types. (updated based on 11th edition) ISBN

Short Notes of CS201

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking

Programming. leads to programming languages. leads to operating systems

Lecture 12: Data Types (and Some Leftover ML)

COSC252: Programming Languages: Basic Semantics: Data Types. Jeremy Bolton, PhD Asst Teaching Professor

Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

Introduction to Programming: Variables and Objects. HORT Lecture 7 Instructor: Kranthi Varala

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

IA010: Principles of Programming Languages

Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++ Performance, memory

Chapter 6. Data Types

Expressions and Assignment Statements

Heap Management. Heap Allocation

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

CPSC 3740 Programming Languages University of Lethbridge. Control Structures

Programming Languages

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

22c:111 Programming Language Concepts. Fall Types I

C++ Important Questions with Answers

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Chapter 3 (part 3) Describing Syntax and Semantics

CSC324 Principles of Programming Languages

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Programming in C++ Indian Institute of Technology, Kharagpur

CS 360 Programming Languages Interpreters

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

CPSC 3740 Programming Languages University of Lethbridge. Data Types

multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall 2011.

MIDTERM EXAMINATION - CS130 - Spring 2003

Expressions & Assignment Statements

Transcription:

https://lambda.mines.edu

Evaluating programming languages based on: Writability: How easy is it to write good code? Readability: How easy is it to read well written code? Is the language easy enough to learn? Reliability: What features does the language provide to make sure our code works as it is supposed to? Feasibility: Does an interpreter or compiler actually exist for the platform we need to use? Is it fast enough for our application?

Evaluating programming languages based on: Writability: How easy is it to write good code? Readability: How easy is it to read well written code? Is the language easy enough to learn? Reliability: What features does the language provide to make sure our code works as it is supposed to? Feasibility: Does an interpreter or compiler actually exist for the platform we need to use? Is it fast enough for our application? A System of Trade-Offs Often times, adding features which improve one metric can harm another metric. Examples to come...

The overall simplicity of a language plays a large role in both writability and readability. For example, these features are non-simple: Feature Multiplicity: Writability, Readability Operator Overloading: Writability, Readability Large Grammars: Writability, Readability

The overall simplicity of a language plays a large role in both writability and readability. For example, these features are non-simple: Feature Multiplicity: Writability, Readability Operator Overloading: Writability, Readability Large Grammars: Writability, Readability Simplicity can be carried too far Assembly languages and esoteric languages generally aren t considered very writable or readable.

Orthogonality: how consistent is the language with itself?

Orthogonality: how consistent is the language with itself? Example of a lack of orthogonality (C++) Parameters are passed by value, unless they were specified with an &. Or unless they were an array.

Orthogonality: how consistent is the language with itself? Example of a lack of orthogonality (C++) Parameters are passed by value, unless they were specified with an &. Or unless they were an array. Example of a lack of orthogonality (C/C++) Arrays can contain data of any type, including pointers. Unless it s a function pointer. But you can wrap that function pointer in a struct and you should be fine. Impacts of poor orthogonality: poor readability, poor writability, and potentially reduced reliability.

Abstraction: The ability to define and use complicated structures and operations in a way that allows implementation to be ignored. Examples: Functions: Simplest form of abstraction. Often taken for granted, but gives us easy recursion. Heap Memory: Imagine trying to create a large unbalanced binary tree in a single-dimensional array. Generics: Allows us to define operations that apply to multiple data types without reimplementing for each type.

Abstraction: The ability to define and use complicated structures and operations in a way that allows implementation to be ignored. Examples: Functions: Simplest form of abstraction. Often taken for granted, but gives us easy recursion. Heap Memory: Imagine trying to create a large unbalanced binary tree in a single-dimensional array. Generics: Allows us to define operations that apply to multiple data types without reimplementing for each type. With your learning group... What other kinds of PL-level abstractions can you name?

Abstraction: The ability to define and use complicated structures and operations in a way that allows implementation to be ignored. Examples: Functions: Simplest form of abstraction. Often taken for granted, but gives us easy recursion. Heap Memory: Imagine trying to create a large unbalanced binary tree in a single-dimensional array. Generics: Allows us to define operations that apply to multiple data types without reimplementing for each type. With your learning group... What other kinds of PL-level abstractions can you name? Good Abstractions: Writability, Readability, Reliability

Some languages come with features designed for reliablitiy: Type Checking: Making sure the type of data can be used with the function or operation you are calling. Independent of static/dynamic: more on this later. Exception Handling: The ability of a running program to intercept run-time errors and take corrective measures. Taint Protection: Protects the security of an application by not allowing privileged operations to be preformed on tainted data (e.g., user input from a web application).

Some languages come with features designed for reliablitiy: Type Checking: Making sure the type of data can be used with the function or operation you are calling. Independent of static/dynamic: more on this later. Exception Handling: The ability of a running program to intercept run-time errors and take corrective measures. Taint Protection: Protects the security of an application by not allowing privileged operations to be preformed on tainted data (e.g., user input from a web application). Some features can harm a language s reliability: Goto: the ability to jump to different locations in the code without restriction. Aliasing: allows two different symbolic names (variables, function names, etc.) to refer to the same data. Think pointers in C/C++.

Expressivity: How easy is it for the programmer to express their solution to a problem in the language? With your learning group: 1 Think of a scenario and two programming languages, where expressing a solution to the problem might be easier in one language than another. 2 If one language is less expressive than another, how might it be less writable? 3 If one language is less expressive than another, how might it be less readable? 4 If one language is less expressive than another, how might it be less reliable? Be prepared to share your answers with the class.

When we refer to "type systems", we aren t just talking about how you have to write the type of a variable in C, whereas you don t in Python. There s a lot that goes in: Static/Dynamic Typing Untyped Systems Implicit/Explicit Type Specification Strong/Weak Typing Gradual Typing Duck Typing -- covered later in the course

In a language with explicit type specification, the type of a variable must be specified: int x = 10; In a language with implicit type specification, the type of a variable need not be specified: var x = 10 Note Explicit/implicit has nothing to do with static/dynamic. We will talk about that in a second...

A binding refers to the association between: a variable and its type, a function and its definition, a type and its representation (e.g., int is 32-bits), or an operation and its symbol (e.g., multiplication is usually *)

A binding refers to the association between: a variable and its type, a function and its definition, a type and its representation (e.g., int is 32-bits), or an operation and its symbol (e.g., multiplication is usually *) Binding time refers to the time at which a binding takes place. Common Binding Times Design time, implementation time, compile time, link time, run time

In a statically typed language, the language design makes it possible to bind the type of any piece of data before run time.

In a statically typed language, the language design makes it possible to bind the type of any piece of data before run time. Advantages: No need to do type checking at run time, this can be done at compile time. Reliability Disadvantages: Generics are needed to create operations and functions that apply to multiple types Writability

In a dynamically typed language, the language design makes it possible to bind the type of any piece of data during run time. Commonly, the type of data is associated with the data itself.

In a dynamically typed language, the language design makes it possible to bind the type of any piece of data during run time. Commonly, the type of data is associated with the data itself. Advantages: Collections can be of mixed type without generics, functions can take multiple types without generics Types can be dynamically created at run time Writability Disadvantages: Type checking must be done at run time; makes things slow Reliability Gradual Typing Gradual Typing can be used to refer to a language which allows optional explicit typing in a dynamically typed language.

In an untyped language, data cannot be bound to a type. Commonly, the functions and operations called on the variables determine the type.

In an untyped language, data cannot be bound to a type. Commonly, the functions and operations called on the variables determine the type. Advantages: No need to do type checking, ever. Feasibility Disadvanges: Reliability

Note Type safety means a language will not allow bits to be intepreted as the incorrect data type. For example: treating the bits of an integer as a floating point number. Implicit type conversions are when a language will automatically convert data types to allow an expression to be computed. Strongly typed programming languages are both type safe and do not allow implicit type conversions. Weakly typed programming languages are either not type safe or allow implicit type conversions. By definition, untyped languages are also weakly typed.

Given the code snippet from a fake language below: int a = 10 a += 5 print(a) Explicit or implicit? Is it possible that the language is statically typed? Is it possible that the language is dynamically typed? Weak or strong?

Given the code snippet from a fake language below: a = 10 a += 5 print(a) Explicit or implicit? Is it possible that the language is statically typed? Is it possible that the language is dynamically typed? Weak or strong?

Given the code snippet from a fake language below: a = eval(user_input()) a += 5 print(a) Explicit or implicit? Is it possible that the language is statically typed? Is it possible that the language is dynamically typed? Weak or strong?

Given the code snippet from a fake language below: ++++++++[>++++[>++>+++>+++>+<<<<-]>+ >+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.-----+----.>>+.>++. Explicit or implicit? Is it possible that the language is statically typed? Is it possible that the language is dynamically typed? Weak or strong?

Strong Weak Static Dynamic Haskell, Rust, Go Python, Ruby, Java C, C++ PHP, JavaScript