Programming Fundamentals. Programming concepts and understanding of the essentials of programming languages form the basis of computing.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
Programming Logic and Design Fourth Edition, Introductory
1 Ch. 3: Interaction Introduction – 3.1 (Reading Assignment – RA) Introduction – 3.1 (Reading Assignment – RA) Models – 3.2, 3.3 (RA) Models – 3.2, 3.3.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
1 Introduction to Software Engineering Lecture 42 – Communication Skills.
Linux+ Guide to Linux Certification, Second Edition
Understanding the Mainline Logical Flow Through a Program (continued)
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Basic Elements of C++ Chapter 2.
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Computer Science 101 Introduction to Programming.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Introduction to Advanced UNIX March Kevin Keay.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
A Guide to Unix Using Linux Fourth Edition
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Computer Science 101 Introduction to Programming.
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
Input, Output, and Processing
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Introduction to Computer Programming Using C Session 23 - Review.
Linux Operations and Administration
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
SE: CHAPTER 7 Writing The Program
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Introduction to Perl Yupu Liang cbio at MSKCC
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Writing Scripts Hadi Otrok COEN 346.
Introduction to Programming Using C An Introduction to Operating Systems.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
CS1010: Intro Workshop.
Topic: Python’s building blocks -> Variables, Values, and Types
CIRC Winter Boot Camp 2017 Baowei Liu
EECS 183 Discussion #9: It’s time to “Git” Python! November 22nd, 2016
Andy Wang Object Oriented Programming in C++ COP 3330
Topic: Python’s building blocks -> Variables, Values, and Types
Unix Shells.
The Command Prompt Commands are the way to “do things” in Unix
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Computer Programming.
Functions, Procedures, and Abstraction
Tutorial of Unix Command & shell scriptS 5027
Introduction to Advanced UNIX
Tutorial Unix Command & Makefile CIS 5027
Linux Shell Script Programming
Experiment No. (1) - an introduction to MATLAB
Matlab Basics Tutorial
Functions, Procedures, and Abstraction
Presentation transcript:

Programming Fundamentals

Programming concepts and understanding of the essentials of programming languages form the basis of computing.

Goals To outline what aspects of a language (specifically R) you might want to teach your students Discuss how to teach this effectively concepts, examples, motivation, context Discuss aspects of the language that not all users are familiar with and to show the logic/simplicity of the language

Three aspects to statistical programming interactive use for exploratory data analysis programming numerically intensive tasks writing functions/software for reuse Obviously related, and there is a natural progression.

Some students won’t have seen a “programming language” before Some may have seen HTML - a declarative language that has no control flow. Many will be unfamiliar with the command-line REPL - Read-Eval-Print-Loop Explain the difference between a spreadsheet and a programming environment.

For some students, we have to get them past the “why isn’t this like X? It’s so lame!” So need to show them how it is useful, and how the language constructs help them to do things. So we have to get them to want to do something which involves, e.g. a lot of repetition. e.g. give them a corpus of messages, 1 per file, or person per file and ask how many messages do we have? Get them to consider the language as a servant.

What is a computation? Transformation from on or more inputs to an output Transition from old state to new state Algorithm set of directions for carrying out a computation in terms of other simpler computations Examples Find the average annual rainfall at a weather station Crop a digital photo Sort the mail by sender in your mail program

Language Model Critical to teach the concepts, structure, logic and design of the language Students will often gravitate to “how to” and mimicking rather than abstracting the specific to gain this “higher understanding” of the language. Syntax versus Semantics and computational model. Getting past details allows them to reason about problems apply their knowledge of one language to another.

Most of the languages we will use are interpreted high-level garbage collected “interactive” & have large libraries R, MATLAB,... - triple of language interpreter environment (packages)

Getting Started Get students familiar with the basics of the environment. Do this with an interactive demo. Place online after class a transcript of session (with comments). How to start (command line or GUI) and quit q() How to use R as a calculator Show them the continuation prompt > 2 * + 3

Terminology Invoke a computation with an expression Pass the expression off to the computer to evaluate Return a value or output of the expression

Syntax Do arithmetic pi Order of operations – log(100) + sin(pi/2) * 15 (log(100) + sin(pi/2)) * 15 Simple plots - curve(sin, -pi, pi) Assign results to variables x = 1 + pi print(x) x result of evaluating a non-assignment => print

Transcript > 1 + pi [1] > log(100) + sin(pi/2) * 15 #multiplication first, log base e [1] > (log(100) + sin(pi/2)) * 15 #parentheses modify order [1] > (log(100, base = 10) + sin(pi/2)) * 15 #change parameter called base [1] 45

Transcript > curve(sin, -pi, pi) #curve function called, 3 arguments > x = 1 + pi > print(x) [1] > x [1] > x = rnorm(100) > mean(x) [1]

Parsing: break down expression – white space, digits 2x vs 2*x, naming conventions No declarations of variables needed or type information

Explore assignments stored in session area - global environment see names of existing variables - objects() where does curve() come from? find(“curve”) search() and the concept of the search path how does R use this > pi= 3 > find("pi") [1] ".GlobalEnv" "package:base"

Remove one or more objects – rm(x, pi) Save variables for future use – save(x, z, file =“myvars.rda”) Restore – load(“myfile.rda”) (Where are these?) Keep track of code – history()

What about ‘+’ in 1 + 2? Does R just know about that? find(“+”) “package:base” is actually a function call `+`(1, 2) In fact, everything in R is a function call simple, single concept that makes lots of things easy to reason about, and several computational tasks feasible. (infix vs function style) Notion of function call is similar to other languages e.g. shell - find. -name '*.R'

Everything's an Object If we can see 'x', can we see '+'? Print the value of + - poor choice! `+` sin We can pass a function as an argument to a function curve(sin) So functions are first class values. In fact, every value is a first class object.

Function Calls What's a function? for now, a black box that takes zero or more inputs, and returns a value, an object. leads to 2 issues: how do we specify the inputs parameter matching what sort of values can we pass in and get out? data structures

Getting Help How to get help (help.start) It is useful to show them the elements of a help page and how to read them, interpret some of the "ambiguous" content, explain some of the terms follow the See Also connect to the manuals which give some more details

Help Page help(mean) Description - what the function does Usage – definition/how to call the function Arguments - purpose of each argument Value – return value from function References - See Also – related functions Examples -

Work environment Where do you write your code? Not in a Word document Text editors – the GUI’s editor, eMacs & ESS How do you find your data, code? File system – trees Simple shell commands – cd, ls, pwd, cp, mv, rm, mkdir, rmdir Can you use a faster computer? – ssh, scp