Introduction to Programming

nutmegactΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 5 χρόνια και 4 μέρες)

180 εμφανίσεις

Introduction to Programming

Comp 110


001 (Summer I, ’08)

Ritesh Kumar
ritesh@cs.unc.edu

Sitterson SN011, MTWRF 9:45a

What is Comp 110


Learn basics of computer programming


We will be using the Java programming language



Problem Solving and Algorithm design


Combining programming constructs



Using Tools to develop and test programs


Text editors; compilers; IDEs

Course website


http://www.cs.unc.edu/~ritesh/Comp110



Lecture slides


Links to tools and additional reading


Schedule; Assignments


Course related news



No Textbook. Please attend the lectures.

Grading


Assignments (40%)


Mid
-
term Exam (20%)


Final Exam (30%)


Class participation (10%)


(?)

Working with Computers


Separate folders for separate assignments


Short but descriptive file/folder names


Back up your work


Losing work before submission = losing credit !


Use your UNC AFS home directory for a backup


You can ask UNC ITS for help


http://help.unc.edu

or 962
-
HELP


Meet me if UNC ITS is unable to help

Computer Programming


Computer Programming


Telling a computer
how

to solve a problem


Algorithm
: The combination of basic programming
constructs to solve a problem


Program
: Machine realization of an algorithm


Similar to Mathematics


Basic symbols to express more complex concepts


One big difference


Algorithms proceed step
-
by
-
step

Algorithms


Example: Find minimum in a set of numbers


1. Take a look at the first number; memorize it


2. Take a look at the next number


3. Is it less than the number we just memorized?


Yes
: Memorize this one instead


No
: Ignore this number


4. Are more numbers are left?


Yes
: Goto step 2


No
: Read out the memorized number. That’s the
required minimum.

What are the Basic Steps?


Take a look…/ Read out


Memorization


Evaluate expressions (less than, any left)


Conditional steps


Ignore number


Goto another step



Very close to a computer’s basic steps


Surprisingly, the above captures
all

basic steps



Take a look…/ Read out


Computer Input/Output; Interaction with outside world


Memorization


“Temporary” working memory


Evaluate expressions (less than, any left)


Arithmetic and Logic


Ignore number


No operation (NOP)


Conditional steps


Goto another step


Control flow: Changing the “direction” of steps


What’s inside a Computer?

Central Processing Unit (CPU, Processor)



-

Arithmetic and Logic


-

Control Flow

Memory

Input / Output (I/O) devices

Basic steps of a computer


Can be very low level


Tedious and cumbersome to write code


Delegate the
translation

to the computer!

High Level description

of program steps

“Compilation”

Program in basic steps of

the computer. (Runnable)


Programming Languages


Assist us in writing programs on a computer


The Java Programming Language

Questions on the course?

Registration

Access to laptop/Lab computers

Scope of the course

Overview of Computer
Software

What runs on my computer?

Some tools we will be using

What runs on my computer?

Processor, Memory

I/O devices

Operating System (OS)

Applications

Web Browser

Email Application


Different kinds of programs


Operating System, Drivers, Services, Applications

Word Processing

File Manager

Compiler Tools

Text Editors

IDEs


Text Editors


Edit and Save
programs


Compiler Tools


Help run programs


IDEs


Combines many tools

Text Editor


For Editing and Saving Programs (any text)


Installation (Notepad2)


Go to the URL on course website


Download the binary zip file and open it


Copy Notepad2.exe somewhere



Syntax Highlighting, Parenthesis matching


Very bare
-
bones programmer’s text editor

Text Editor Usage Demo

Notepad2,

File Manager,

AFS home directory

Compiler Tools


The Java SE Software Development Kit


Contains compilers and libraries


Installation (JavaSE)


Visit the URL on course web page


Download and run the installer (Java 6 update 6)


It will install in C:
\
Program Files
\
Java
\
jdk1.6.0_06


Java has 2 step compilation


jdk1.6.0_06
\
bin
\
javac => java files to bytecode


jdk1.6.0_06
\
bin
\
java => bytecode to machine code

Java Compiler Tools Demo

javac


the Java compiler

java


the “bytecode” compiler

cmd


Windows command line

JSwat and Netbeans (optional)


Debuggers (bug = error in program)


Let you step through your program


JSwat: standalone debugger


Installation similar to JavaSE


Note: Run using command line from the program folder


Netbeans IDE


Combination of text editing / compilation / debug


Has
many

more features


Not recommended if you are new to programming

JSwat and Netbeans Demo

JSwat


Stepping through programs

Netbeans


Editing, Compilation, Debug
and Running