The Beauty and Joy of Computing

Similar documents
CS10 : The Beauty and Joy of Computing

CS10 : The Beauty and Joy of Computing

CS39N The Beauty and Joy of Computing

The Beauty and Joy of Computing

The Beauty and Joy of Computing Quest (first exam) in in 16 days!! Lecture #3 : Functions

The Beauty and Joy of Computing

The Beauty and Joy of Computing

Dr. Chuck Cartledge. 18 Feb. 2015

The Beauty & Joy of Computing


CS10 The Beauty and Joy of Computing

Anders Møller Michael Schwartzbach Erik Ernst Hans Hüttel

ACSC300: Logic Programming

Com S 541. Programming Languages I

The Beauty and Joy of Computing

The Beauty and Joy of Computing

CPS122 Lecture: Course Intro; Introduction to Object-Orientation

Programming for Engineers in Python

CSc 372 Comparative Programming Languages

Programming Paradigms and Languages Introduction. dr Robert Kowalczyk WMiI UŁ

Introduction to Programming

CS39N The Beauty and Joy of Computing

Preface A Brief History Pilot Test Results

New Programming Paradigms

01 INTRODUCTION TO COURSE

Course Syllabus. Programming Language Paradigms. Spring - DIS Copenhagen. Semester & Location: Elective Course - 3 credits.

Programming for Mobile Computing

CS201 - Assignment 7 Due: Wednesday April 16, at the beginning of class

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

Seminar in Programming Languages

CSC 111 Introduction to Computer Science (Section C)

University of California, Berkeley College of Engineering

AP Computer Science A (Java) Scope and Sequence

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Introduction to Prolog

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CS112 Lecture: Introduction to Karel J. Robot

Classes, objects, methods and properties

CS 32. Lecture 1: oops

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

CS10 The Beauty and Joy of Computing

Object Oriented Programming

Einführung in die Programmierung Introduction to Programming

Lecture 6 Introduction to Objects and Classes

Functional Programming Invades Architecture. George Fairbanks SATURN May 2017

CS 242. Fundamentals. Reading: See last slide

Programming Languages 2nd edition Tucker and Noonan"

COURSE OUTLINE. Faculty of Computing, Universiti Teknologi Malaysia

CS10 The Beauty and Joy of Computing

CS511 Design of Database Management Systems

Computer Principles and Components 1

CS317 File and Database Systems

Berkeley Scheme s OOP

Lecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018

Introduction To Programming Using Java: An Object- Oriented Approach (2nd Edition) By David Arnow, Scott Dexter

Computing and Programming

Overview of Data Management

Whereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

CS3110 Spring 2017 Lecture 12: DRAFT: Constructive Real Numbers continued

Slide 1 CS 170 Java Programming 1 Testing Karel

Functional Programming Principles in Scala. Martin Odersky

Level: M.Ed. Credit Hour: 3 (2+1) Semester: Second Teaching Hour: 80(32+48)

CS61C : Machine Structures

Underlying computer system = hardware + software

Monty Python and the Holy Grail (1975) BBM 101. Introduction to Programming I. Lecture #03 Introduction to Python and Programming, Control Flow

Database Technology Introduction. Heiko Paulheim

FP and states? Lucid

Boca Raton Community High School AP Computer Science A - Syllabus 2009/10

Programming language design and analysis

Algorithms. Definition. Algorithms we've seen... Part 1: The Basics

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

15 Minute Traffic Formula. Contents HOW TO GET MORE TRAFFIC IN 15 MINUTES WITH SEO... 3

Computer Science 32 Object-Oriented Oriented Design and Implementation (in C++ on Linux)

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

The Beauty and Joy of Computing

PROFESSIONAL PYTHON BY LUKE SNEERINGER DOWNLOAD EBOOK : PROFESSIONAL PYTHON BY LUKE SNEERINGER PDF

Outline. Computer Science 331. Information Hiding. What This Lecture is About. Data Structures, Abstract Data Types, and Their Implementations

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

Welcome to. Instructor Marc Pomplun CS 470/670. Introduction to Artificial Intelligence 1/26/2016. Spring Selectivity in Complex Scenes

Introduction & Review

CMPT 354: Database System I. Lecture 5. Relational Algebra

Advances in Programming Languages: Exam preparation and exam questions

Lecture 1 - Introduction (Class Notes)

Computer Organization & Assembly Language Programming

CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP. Sadia Rain Sharmin Week of May 7, 2018

Smalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80)

CSCI 102 Fall 2010 Exam #1

Tutorial on VHDL and Verilog Applications

Welcome to CS 115 (Winter 2018)

Computer Science Curriculum for International Students

STUDY GUIDE: MASTER S DEGREE IN ECONOMIC POLICY

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Programs as Models. Procedural Paradigm. Class Methods. CS256 Computer Science I Kevin Sahr, PhD. Lecture 11: Objects

Basics of Object Oriented Programming FCITR MAGAZINE DR. SHAKEEL AHMAD

CS61A Lecture 26 Logic Programming. Jom Magrotker UC Berkeley EECS August 1, 2012

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Curriculum Mapping for National Curriculum Statement Grades R-12 and Oracle Academy.

Transcription:

The Beauty and Joy of Computing Lecture #5 Programming Paradigms UC Berkeley EECS Sr Lecturer SOE Dan Quest (first exam) in in 14 days!! A new non-profit foundation is dedicated to growing computer programming education. Their goals are to spread the word that there s a worldwide shortage of talent, and list all available courses!! code.org!

Programming Paradigms Lecture What are they? ú Most are Hybrids! The Four Primary ones ú Functional ú Imperative ú Object-Oriented OOP Example: Skecthpad ú Declarative Turing Completeness Summary UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (2)

en.wikipedia.org/wiki/programming_paradigm! What are Programming Paradigms? The concepts and abstractions used to represent the elements of a program (e.g., objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignation, evaluation, continuations, data flows, etc.). Or, a way to classify the style of programming. UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (3)

! byob.berkeley.edu Of 4 paradigms, how many can BYOB be? a) 1 (functional) b) 1 (not functional) c) 2 d) 3 e) 4 UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (4)

Most Languages Are Hybrids! This makes it hard to teach to students, because most languages have facets of several paradigms! ú Called Multi-paradigm languages ú Scratch too! It s like giving someone a juice drink (with many fruit in it) and asking to taste just one fruit! UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (5)

en.wikipedia.org/wiki/functional_programming! Functional Programming (review) Computation is the evaluation of functions ú Plugging pipes together ú Each pipe, or function, has exactly 1 output ú Functions can be input! Features ú No state E.g., variable assignments ú No mutation E.g., changing variable values ú No side effects Examples (tho not pure) ú Scheme, Scratch BYOB f(x)=(x+3)* x! x! x 3! x! +! *! UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (6)

en.wikipedia.org/wiki/imperative_programming! Imperative Programming Sequential Programming Computation a series of steps ú Assignment allowed Setting variables ú Mutation allowed Changing variables Like following a recipe. E.g., Procedure f(x) ú ans = x ú ans = ans ú ans = (x+3) * ans ú return ans Examples: (tho not pure) ú Pascal, C f(x)=(x+3)* x! UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (7)

en.wikipedia.org/wiki/object-oriented_programming! Object-Oriented Programming (OOP) Objects as data structures ú With methods you ask of them These are the behaviors ú With local state, to remember These are the attributes Classes & Instances ú Instance an example of class ú E.g., Fluffy is instance of Dog Inheritance saves code ú Hierarchical classes ú E.g., pianist special case of musician, a special case of performer Examples (tho not pure) ú Java, C++ www3.ntu.edu.sg/home/ehchua/ programming/java/images/oop-objects.gif! UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (8)

en.wikipedia.org/wiki/sketchpad! OOP Example : SketchPad Dr. Ivan Sutherland ú Father of Computer Graphics ú 1988 Turing Award ( Nobel prize for CS) ú Wrote Sketchpad for his foundational 1963 thesis The most impressive software ever written First ú Object-oriented system ú Graphical user interface ú non-procedural language Spent the past few years doing research @ Berkeley in EECS dept! UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (9)

OOP in BYOB UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (10)

en.wikipedia.org/wiki/declarative_programming! Declarative Programming Express what computation desired without specifying how it carries it out ú Often a series of assertions and queries ú Feels like magic! Sub-categories ú Logic ú Constraint We saw in Sketchpad! Example: Prolog Anders Hejlsberg The Future of C# @ PDC2008 channel9.msdn.com/pdc2008/tl16/ UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (11)

Declarative Programming Example Five schoolgirls sat for an examination. Their parents so they thought showed an undue degree of interest in the result. They therefore agreed that, in writing home about the examination, each girl should make one true statement and one untrue one. The following are the relevant passages from their letters: Betty ú Kitty was 2 nd ú I was 3 rd Ethel ú I was on top ú Joan was 2 nd Joan ú I was 3 rd ú Ethel was last Kitty ú I came out 2 nd ú Mary was only 4 th Mary ú I was 4 th ú Betty was 1 st UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (12)

Of 4 paradigms, what s the most powerful? a) Functional b) Imperative c) OOP d) Declarative e) All equally powerful UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (13)

en.wikipedia.org/wiki/turing_completeness Turing Completeness ironphoenix.org/tril/tm/! A Turing Machine has an infinite tape of 1s and 0s and instructions that say whether to move the tape left, right, read, or write it ú Can simulate any computer algorithm! A Universal Turing Machine is one that can simulate a Turing machine on any input A language is considered Turing Complete if it can simulate a Universal Turing Machine ú A way to decide that one programming language or paradigm is just as powerful as another Turing Machine by Tom Dunne Xkcd comic Candy Button Paper UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (14)

Ways to Remember the Paradigms Functional ú Evaluate an expression and use the resulting value for something Imperative ú First do this and next do that Object-oriented ú Send messages between objects to simulate the temporal evolution of a set of real world phenomena Declarative ú Answer a question via search for a solution UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (15)

Summary Each paradigm has its unique benefits ú If a language is Turing complete, it is equally powerful ú Paradigms vary in efficiency, scalability, overhead, fun, how vs what to specify, etc. Modern languages usually take the best from all ú E.g., Scratch Can be functional Can be imperative Can be object-oriented Can be declarative UC Berkeley The Beauty and Joy of Computing : Programming Paradigms (16)