What is a programming language?

Slides:



Advertisements
Similar presentations
Program Looping EE2372 Software Design I Dr. Gerardo Rosiles.
Advertisements

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 12P. 1Winter Quarter User-Written Functions.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Winter 2013.
Exercise 1 Generics and Assignments. Language with Generics and Lots of Type Annotations Simple language with this syntax types:T ::= Int | Bool | T =>
Programming Languages Section 1 1 Programming Languages Section 1. SML Fundamentals Xiaojuan Cai Spring 2015.
Recap 1.Programmer enters expression 2.ML checks if expression is “well-typed” Using a precise set of rules, ML tries to find a unique type for the expression.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Fall 2011.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
CS 312 Spring 2004 Lecture 18 Environment Model. Substitution Model Represents computation as doing substitutions for bound variables at reduction of.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Functional Programming Element of Functional Programming.
CIS Computer Programming Logic
Principles of programming languages 5: An operational semantics of a small subset of C Department of Information Science and Engineering Isao Sasano.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
A Third Look At ML Chapter NineModern Programming Languages, 2nd ed.1.
CSE 341 : Programming Languages Lecture 2 Functions, Pairs, Lists Zach Tatlock Spring 2014.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Programming Languages Dan Grossman 2013 ML Expressions and Variable Bindings.
CS314 – Section 5 Recitation 9
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2017.
Learning to Program D is for Digital.
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Autumn 2017.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Representation, Syntax, Paradigms, Types
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Winter 2013.
Variables and Primative Types
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Spring 2017.
Repetition-Counter control Loop
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Arrays, For loop While loop Do while loop
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Winter 2013.
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018.
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2013.
Functional Programming
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Winter 2018.
Representation, Syntax, Paradigms, Types
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2016.
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Zach Tatlock Winter 2018.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Forth A stack language.
Recursion (part 1) October 24, 2007 ComS 207: Programming I (in Java)
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Autumn 2018.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Type & Typeclass Syntax in function
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Representation, Syntax, Paradigms, Types
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2016.
C Programming Getting started Variables Basic C operators Conditionals
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Spring 2016.
Representation, Syntax, Paradigms, Types
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2017.
Assignments and Procs w/Params
CSE 341 Lecture 11 b closures; scoping rules
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
An Overview of C.
What is a programming language?
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Spring 2019.
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2019.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2019.
Review Functions Lists Today: Let expressions
Presentation transcript:

What is a programming language? Here are separable concepts for defining and learning a language: syntax: how do you write the various parts of the language? semantics: what do programs mean? (One way to answer: what are the evaluation rules?) idioms: how do you typically use the language to express computations? libraries: does the language provide “standard” facilities such as file-access, hashtables, etc.? How? tools: what is available for manipulating programs in the language? (e.g., compiler, debugger, REP-loop)

ML basics A program is a sequence of bindings One kind of binding is a variable binding val x = e ; (semicolon optional in a file) A program is evaluated by evaluating the bindings in order A variable binding is evaluated by: Evaluating the expression in the environment created by the previous bindings. This produces a value. Extending the (top-level) environment to bind the variable to the value. Examples of values: 13, 4.8, true, “hello”, [3, 4, 5], (8, 8.2)

Critical language concepts Expressions have a syntax (written form) E.g.: A constant integer is written as a digit-sequence E.g.: Addition expression is written e1 + e2 Expressions have types given their context E.g.: In any context, an integer has type int E.g.: If e1 and e2 have type int in the current context, then e1+e2 has type int Expressions evaluate to values given their environment E.g.: In any environment, an integer evaluates to itself E.g.: If e1 and e2 evaluate to c1 and c2 in the current environment, then e1+e2 evaluates to the sum of c1 and c2

Function definitions A second kind of binding is for functions (like Java methods without fields, classes, statements, ...) Syntax: fun x0 (x1 : t1, ..., xn : tn) = e Typing rules: Context for e is (the function’s context extended with) x1:t1, ..., xn:tn and : x0 : (t1 * ... * tn) -> t where : e has type t in this context (This “definition” is circular because functions can call themselves and the type-checker “guessed” t.) (It turns out in ML there is always a “best guess” and the type-checker can always “make that guess”.)

Function applications (aka calls) Syntax: e0 (e1,...,en) (parens optional for one argument) Typing rules (all in the application’s context): e0 must have some type (t1 * ... * tn) -> t ei must have type ti (for i=1, ..., i=n) e0 (e1,...,en) has type t Evaluation rules: e0 evaluates to a function f in the application’s environment ei evaluates to value vi in the application’s environment result is f ’s body evaluated in an environment extended to bind xi to vi (for i=1, ..., i=n). (“an environment” is actually the environment where f was defined)