Programming Languages Meeting 14 December 9/10, 2014.

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Names and Bindings.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
CSC 4630 Perl 1. Perl Practical Extraction and Support Language A glue language under UNIX Written by Larry Wall Claimed to be the most portable of scripting.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
High-Level Programming Languages
Practical Extraction & Report Language Picture taken from
Programming Languages Structure
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
JavaScript, Third Edition
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that.
Object-Oriented Programming in C++
CS 355 – Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
Chapter 1 - Introduction
1 Programming Language History and Evolution In Text: Chapter 2.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Perl By Gabe and Ted. History Perl was created by Larry Wall while working at NASA’s Jet Propulsion Labs. Larry Wall also created patch which is in widespread.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Geog Basic Skills in Scientific Programming Syllabus, Introduction, Fundamentals of IDL Syntax.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Types(1). Lecture 52 Type(1)  A type is a collection of values and operations on those values. Integer type  values..., -2, -1, 0, 1, 2,...  operations.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Allyson M. Hoss, January 14, 2008 CSC 7101 Programming Language Structures Spring 2008 Louisiana State University.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Programming Languages Meeting 12 November 18/19, 2014.
Language Paradigms CS655.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Organization of Programming Languages Meeting 37 April 18, 2016.
Programming Language History and Evolution
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Programming Languages 2nd edition Tucker and Noonan
Concepts of Programming Languages
Why study programming languages?
PROGRAMMING LANGUAGES
Programming Language Design Concepts
Representation, Syntax, Paradigms, Types
Programming Language History and Evolution
Programming Languages
Representation, Syntax, Paradigms, Types
Programming Languages 2nd edition Tucker and Noonan
High Level Programming Languages
Representation, Syntax, Paradigms, Types
Programming Languages
Principles of Programming Languages
Representation, Syntax, Paradigms, Types
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
The Selection Structure
INTRODUCTION to PERL PART 1.
Presentation transcript:

Programming Languages Meeting 14 December 9/10, 2014

CATS

Planning Final Exam, next week, Tuesday, December 16, 2:30 – 5:00 pm, MSC 290 Or Wednesday, December 17, 6:15 – 8:45 pm, MSC G86

Topics for Final Syntax and syntax specification: EBNF – Nonterminal, terminal, production, start symbol – Grammar of expressions Inferred precedence and association – Syntax trees Abstract syntax

Topics (1.1) Semantics and semantic specification – Env, Loc, Store, Value, Memory – Program functions – Backus notation for functional programming

Topics (2) Semantics examples – REF, a language of pointers – Multiple assignment statements Control structures – Sequence – While – If-then – For

Topics (3) Parameter passing – Value – Result – Value-result – Reference – Name

Topics (4) Functional programming – Lists – Atoms – Primitive functions – Functionals – User-defined functions – Predicates

Topics (4.1) Developing from primitives and functionals – Use of recursion Catching error conditions – Proper error messages Measures of lists – Length – Depth

Topics (5) Scripting languages – AWK – Perl Regular expressions

AWK Questions

AWK Programs {for (w=1;w<=NF;w++) count[$w]++} END {for (w in count) print count[w],w} /^$/ {count++} END {print count} /

Paradigms Programming paradigm: pattern of problem- solving thought that underlies a particular genre of programs and languages. Four main programming paradigms: – Imperative – Object-oriented – Functional – Logic (declarative)

Imperative Follows the classic von Neumann-Eckert model: – Program and data are indistinguishable in memory – Program: a sequence of commands – State: values of all variables when program runs – Large programs use procedural abstraction Examples of imperative languages: – Cobol, Fortran, C, Ada, Perl – Historically: PL1, Algol, Pascal

Object-oriented Collection of objects (instantiated from classes) that interact by passing messages that transform the state. Need to know: – Ways of sending messages – Inheritance – Polymorphism Examples of OO languages: – Smalltalk, Modula, Java, C++, C#, Python

Functional Models a computation with a collection of functions acting on a set of objects, usually lists. – Input: domain of the function – Output: codomain of the function Functional languages are characterized by: – Functional composition – Recursion Examples of functional languages: – Lisp, Scheme, ML, Haskell

Logical Logic programming declares what outcome the program should accomplish, rather than how it should be accomplished. Programs are: – Sets of constraints on a problem – Achieve all possible solutions – Nondeterministic, in some cases Example of a logic programming language: – Prolog

Special Languages Symbolic computation – Macsyma, Mathematica, Maple, Reduce Mathematical – APL, Basic, Cayley Music – ChucK Markup – HTML, MusicXML, LaTeX Scripting – AWK, Perl, JavaScript, PHP and hundreds more for every special circumstance

PERL Practical Extraction and Support Language A glue language under Unix Written by Larry Wall See

PERL Scripting language More powerful than AWK More flexible than shell scripts Syntax derived from C Large language Later versions contain classes Many irregularities in design Many alternatives for syntax

PERL Beginning assumptions and notations Statements are terminated by ; (semicolon) Comments start with # and occupy the rest of the line. – NO two-line comments Parentheses around arguments to built-in functions are optional

PERL First line of program is an interpreter directive, written as a special type of comment, giving the full path to the Perl interpreter #!/usr/local/bin/perl -w

Example 1 #!/usr/local/bin/perl –w print(“Hello, world!\n”);

Example 1 #!/usr/local/bin/perl –w print(“Hello, world!\n”); Inserts new line character

PERL Scalars – Integer, real, string Identifier must start with $ Arrays – Indexed by integers Identifier must start – Indexed by strings Identifier must start with %

Example 2 #!/usr/local/bin/perl –w print(“What is your name? ”); $name = ; chomp($name); print “Hello, $name!\n”;

Example 2 #!/usr/local/bin/perl –w print(“What is your name? ”); $name = ; chomp($name); print “Hello, $name!\n”; Critical space

Example 2 #!/usr/local/bin/perl –w print(“What is your name? ”); $name = ; #Reads one line chomp($name);#Cuts off EOL print “Hello, $name!\n”;

PERL Control structures if-then-elsif foreach $element (%list) { … }

Example 3 #!/usr/local/bin/perl –w print “What is your name? ”; $name = ; chomp($name); if ($name eq “Nico”) {print “Hello, $name! Glad you’re here.\n”} elsif ($name eq “Daphne”) {print “Going outside, $name?\n”} else {print “Hello, $name.\n”};

PERL Dynamically typed – Type inferred from operations – Compare 2 < 10 (true) 2 lt 10 (false) 2 < “10” (true) “2” lt 10 (false) Numbers, strings, regular expressions Operators are not overloaded

Arrays of Strings Can be initialized with a list of = (“camel”,”llama”,”alpaca”); Or use the keystroke saving function llama alpaca); Note that an individual element is a string so that the string identifier syntax must be used $words[0] has value camel

Array Bounds Out of bounds arrays – Impossible with associative arrays: strings are not presumed to have order (in the sense of a next function) – Impossible with integer indexed = (2,3,5,7); $a[7] = 17; We’ll check the Env and Store

Scalar Operators Numeric: + - * / ** % Numeric comparison: = > != String:. (for concat) x (for multiple concat) String comparison: lt le eq ge gt ne Assignment: = (carries value of expression) binary assignment: += *=.= etc increment: ++$i $i++ (increment then assign vs. assign then increment)

Parameter Passing Parameter passing – Formal parameters not included – Values of arguments to a function come in the – Example, the call range(1,74,3) puts 1 in $_[0], 74 in $_[1], and 3 in $_[2] – Thus, a function can have a varying number of arguments.

Parameter Passing (2) If parameter values are passed to a procedure (subroutine in PERL language) in an array local to the procedure, how are values returned to the calling program? Options –