CSCI 3200: Programming Languages

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

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Copyright © 2005 Elsevier Imperative languages Group languages as –imperative von Neumann(Fortran, Pascal, Basic, C) object-oriented(Smalltalk, Eiffel,
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
Programming Languages Structure
Introduction and Syntax. Course objectives Discuss features of programming languages. Discuss how the features are implemented in a simple computer architecture.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
High-Level Programming Languages: C++
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Chapter 1. Introduction.
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.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
Programming Languages: Scratch Intro to Scratch. Lower level versus high level Clearly, lower level languages can be tedious Higher level languages quickly.
Chapter 1 - Introduction
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Programming Languages
CPS120: Introduction to Computer Science Variables and Constants.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
The language focusses on ease of use
CMIT100 Chapter 14 - Programming.
Concepts of Programming Languages
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Concepts of Programming Languages
Why study programming languages?
CS 3304 Comparative Languages
CSCI 3200: Programming Languages
Basic 1964 PC general purpose Imperative Small Easy to use.
Lecture 1 Introduction Richard Gesick.
CS 3304 Comparative Languages
Chapter 1 Preliminaries.
PROGRAMMING LANGUAGES
Topic: Python’s building blocks -> Variables, Values, and Types
Problem Solving Using C: Orientation & Lecture 1
CS 363 – Chapter 1 What is a programming language? Kinds of languages
课程名 编译原理 Compiling Techniques
Chapter 1 Preliminaries.
Choice of Programming Language
Evolution of programming languages
CS 3304 Comparative Languages Fall 2011
Welcome to Programming Languages!
Chapter 1 Introduction.
Problem Solving.
Problem Solving Using C: Orientation & Lecture 1
Chapter 1 Preliminary. Chapter 1 Preliminary 1.1 Reasons for Studying Concepts of Programming Languages Increased capacity to express ideas Improved.
COP4020 Programming Languages
CS 3304 Comparative Languages Fall 2011
Programming Languages 2nd edition Tucker and Noonan
CS105 Introduction to Computer Concepts Intro to programming
Programming Languages and Paradigms
High Level Programming Languages
Low Level Programming Languages
Problem Solving Using C: Orientation & Lecture 1
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
School of Computer & Information Engineering,
Chapter 1 Preliminaries.
Programming Languages and Compilers (CS 421)
Reasons To Study Programming Languages
Chapter 1 Preliminaries.
SPL – PS1 Introduction to C++.
Presentation transcript:

CSCI 3200: Programming Languages Instructor: Dr. Erin Wolf Chambers Office: 301 Ritter Hall Email: erin.chambers@slu.edu

Today: Syllabus overview (boring but necessary) HW 1 is posted – due next Wednesday An intro to programming languages

First Question: What programming languages have you used before? Python C++/C Java? Matlab? Others?

Categories of langauges There are many ways to categorize programming languages. Main starting point: High level versus low level Examples? In fact, initially, there only were extremely low level languages: each machine architecture had its own built in language.

High level languages This began to change in the 1950s with Fortran, when people realized it would make more sense to have common languages and then translate them for the machine This is the advent of the notion of compilation. The idea was slow to catch on, since compiled code was usually slower to run.

Why so many? Programming languages are still very much evolving: Structured programming (using loops and function calls) was developed in the late 1960’s. Object orientation was only introduced in the 1980’s. Modern scripting languages (Ruby, Python, etc.) are often only 10-20 years old

Why so many? (cont) Special purpose languages are very common: C is good for low level coding, like OS development. Prolog is good for logical relationships and AI applications. Awk is good for character and string manipulations. Python and perl are good for scripting.

Other issues: Ease of use Learning curve Standardization Open source Good compliers available Economics and hisotry Pure inertia

Paradigms of computing The major paradigms we’ll discuss this semester are: Declarative languages: focus is on what the computer should do. Imperative languages: focus is on how the computer should do something. (This is the dominant paradigm.)

Imperative language categories von Neumann: Fortran, C, etc. - based on computation with variables Scripting languages: bash, awk, perl, etc. - subset of von Neumann, but tailored for ease of expression over speed Object oriented: - traces back to Simula 67, and descended from von Neumann, but focus is on objects rather than pure variables

Declarative language categories 1. Functional languages: Lisp, Scheme, Haskell, etc. based on recursive definitions of functions Inspired by lamba calculus 2. Logic based: prolog computation is based on attempts to find values that satisfy specified relationships 3. Data flow: id, val flow of information (tokens) among nodes

Some examples: Consider the gcd algorithm (finding the greatest common divisor) Euclid’s algorithm:

GCD in C int main() { int i = getint(), j = getint(); while (i != j) { if (i > j) i = i - j; else j = j - i; } putint(i);

GCD in Haskell Haskell is based entirely on function calls – there is essentially no such thing as a variable in this language. selfGCD :: Integral f => f -> f -> f selfGCD a b = if b == 0 then a else selfGCD b (mod a b)

GCD in prolog Prolog is all about stating true axioms, and then evaluating for something to be true based off these gcd(X,Y,Z):- X>=Y, X1=X-Y, gcd(X1,Y,Z). gcd(X,Y,Z):- X<Y, X1=Y- X, gcd(X1,X,Z). gcd(0,X,X):- X>0.

A note on outcomes (or: why the heck study this?) Professionally, choosing an appropriate language is a key skill Studying language design will make learning new languages easier This also establishes a common terminology for comparison of languages It is difficult to understand hidden “features” of various languages – we’ll look at a lot of them. Need to understand actual implementation cost.

So: diving in A first distinction is compilation versus interpretation

Compilation vs. Interpretation In reality, the difference is not so clear cut. These are not opposites, and most languages fall somewhere in between on the spectrum In general, interpretation gives greater flexibility (think python), but compilation gives better performance (think C++)

Compilation vs. Interpretation Most languages do include a mix of these: Note that compilation doesn’t have to produce machine code – just a translation to another language Think of Java, for example

Implementation of compilation Preprocessing: removes white space and comments groups characters into tokens expands abbreviations identifies higher level syntactic structures – i.e. loops and subroutines This is often known as scanning – we’ll spend the first few weeks talking about it.

Compiling (cont.) Next: routines and linking Compiler uses a linker program add subroutines from a library You’ve done this if you ever used a #include from the standard template library

Compilers (cont) Post-compilation assembly output: why?? Makes debugging and optimizing easier, since assembler is MUCH easier than machine code Isolates compiler from low level machine changes – many architectures can use the same assembly, but machine level code is very specific

Compilers (cont) In interpreted languages, the compiler still generates code. But assumptions about inputs are not finalized. At runtime, checks assumptions. If valid, runs quickly. If not, a dynamic check reverts to the interpreter.

Phases of compilation

Next time We’ll be spending our first few weeks on compilers, since a basic understanding of this helps to understand programming language design. Remember, compilers is usually a class all by itself! We’ll be covering just enough of the basics to get us by. We won’t even really get to the lower level stuff from the previous slide – go take a compilers course to cover that. Next up: scanning and tokenizing