overview of computer sciencecsweb.cs.wfu.edu/~pauca/csc101/6-programmingbasics.pdfoverview of...

15
Overview of Computer Science CSC 111 - Spring 2013 Programming March 1 Friday, March 1, 13

Upload: lykien

Post on 28-Apr-2018

232 views

Category:

Documents


4 download

TRANSCRIPT

Overview of Computer ScienceCSC 111 - Spring 2013

Programming

March 1

Friday, March 1, 13

Application Development• All apps developed in some computer language

• Process

Compiler

Write programin high level language

compile to generate executable Run the executable

Friday, March 1, 13

Executable• Written in machine language

• Specific to each CPU, e.g. Intel, AMD, etc

• In binary, sequence of 0s and 1s, e.g. 0011010111

• Only specific CPU can interpret

• Assembly language

• Mnemonic representation of machine code

Friday, March 1, 13

High-Level Language• Human-oriented language

• Natural language constructs

• Mathematical notation

• Syntax and semantics rules

• Enables human to write instructions for a computer to execute

• No ambiguity in these instructions

• Examples:

• Java, C++, C#, Objective-C, Javascript, etc.

Friday, March 1, 13

Sample Objective-C code

Friday, March 1, 13

Compiler• Translates high-level code into machine-specific

code

• Java compiler

• C++ compiler

• C# compiler,

• Objective-C compiler

• Programmer uses compiler to translate source code to executable

Friday, March 1, 13

iPad App Source Code

Friday, March 1, 13

iPad App Source Code• Environments

• Xcode, uses Objective-C and compiler

• HTML5 + Javascript + Objective-C

• Other

• Android apps are similarly developed

• Language: Java, Java compiler

• HTML5 + Javascript + Java

• Environment: Eclipse, etc.

Friday, March 1, 13

Sample iPad App• Verbal Victor

• Developed at Wake Forest in 2010 for people with speech and communication disabilities

• Sold over 5000 copies world wide at $7 each

• Conventional devices: $300 - $7000

• Severe physical disability: >$25,000

• Cost of developing an App?

• Anywhere from $10K to $100K or more...

Friday, March 1, 13

Verbal Victor

Friday, March 1, 13

Computer Programming• Computer program

• A sequence of instructions written in a particular computer language

• Computer reads in and executes program one instruction at the time

• Programming

• Highly creative process

• Develop a solution for a particular problem

• Solution specified as a well-defined, unambiguous sequence of instructions is called an algorithm

Friday, March 1, 13

Algorithms• Examples:

• Can you write clear instructions for finding the winning number among a deck of lottery tickets?

• If I think of a number between 0 and 100, can you write instructions for guessing my number in less than 100 tries? less than 50? less than 7?

• If pi = 4 - 4/3 + 4/5 - 4/7 + ... can you find a way to approximate pi?

• If I give you 100 numbers, can you instructions for sorting them from largest to smallest?

Friday, March 1, 13

Programming Concepts• Control flow• A computer follows your instructions

one at the time, from top to bottom

• It never skips an instruction

• It does not guess the meaning of it

• Loop/iteration structures• Allow the computer to repeat certain

instructions until certain conditions is met (or forever)

• Conditional statements• Allow the computer to make a decision

about whether it needs to execute an instructions or not (if, if-else)

Friday, March 1, 13

Programming Concepts• Variables• Allow a program to store and recall data

• Random numbers• Powerful mechanism

• Used to simulate intelligence in a computer program

• Parallel execution in Scratch• Any code block starting with

is executed simultaneously

Sebastien's blog: Scratch - Programming and Component Assembly for All

Friday, March 1, 13

Why Scratch?• Very Easy to learn

• No syntax issues

• Only semantics and problem solving

• Can be embedded directly into a website

• Using the Adobe Flash pluggin

• Can be turned into an Android app

• Using App Inventor

• Easy to put into any Android deviceFriday, March 1, 13