Introduction To Program M Ing
Introduction To Program M Ing
Introduction To Program M Ing
Instructor:
Yong-nian Tang
Brookhaven National Laboratory
Working on accelerator control
631-344-7022 (BNL Phone #)
[email protected]
www2.sunysuffolk.edu/tangy/cst112
Outline
Announcements
Slides
Projects
Attendance and project status
5
Introduction to Programming
Attendance Policy
Attending classes is very important
Firm but flexible policy
If you can not attend a class,
call 344-7022 or
email [email protected]
Attendance
Grades: 10% goes to the
final grade. However, more points will be
deducted for many absences.
6
D efi
ning Com puters
A computer is an electronic
device
accepts input
processes and stores data
produces output
and tablet
Small & lightweight.
Portable
Netbook: browsing
Internet
Tablets (7 and 10,)
sound card
H ardw are:CPU
CPU - micro processor
A silicon chip
designed to
manipulate data
The brain of a
computer.
64-bit CPUs and 32bit CPUs
Q uestion
1. What are the two
most expensive
components in a
computer?
Q uestion
2. A byte can store
256 different
numbers, why do we
need two bytes to
store an English
character?
(1024) bytes
Megabyte (MB) = one million
(1024 KB) bytes
Gigabyte (GB) = one billion bytes
Terabyte (TB) = one trillion bytes
storage locations.
Five types of memory:
CPU
Also called volatile memory,
primary memory, and main
memory.
Most important memory type.
256 MB to many GBs.
Fast CPU + big memory + (fast
graphical card) a fast computer.
flash drive
from 32 MB to 16 GB
and more
Plug directly into the
USB port (hot
operation)
Rewritable
Best portable storage
Small and
inexpensive:
$1.50/GB
Persistent
Size
Location
Memory
Fast
No
Limited
On board
Storage
Slow
Yes
Unlimited(?)
External
Q uestion
3. When we talk about
memory and storage,
how do you compare
computers and
people?
storage functions.
Not on the motherboard slow
I/O always is the slowest part of
any program execution
(diagonal in
inches)
Resolution (in
pixels)
Setting the
screen
resolution.
Inkjet printer
H ardw are:Printer
Turn OFF the printer when not
44
Mouse port
Audio
connection
Monitor port
FireWire port
USB ports
Network port
Speaker and
microphone
connections
Phone line
connection
System utilities
Application software
Softw are:Introduction
Software manipulates and
processes data
Data:
Strings, numbers, figures, sounds,
images, and graphics
Softw are:Introduction
File --- named collection of stored
data.
Executable file can be run to perform
a specific task.
Data file contains data.
Everything in a computer is
character is
represented
by an ASCII
number.
ASCII numbers
defined by
ANSI.
53
Operating systems
Utilities
Device drivers
Programming languages
(GUI)
Others
system
System administrator (SA):
configure and maintain the system
End user: use the system
Using GUI (Graphical User Interface)
Manipulating files
57
58
59
Device drivers
Drives a specific device (drive).
The main task to install a device is to
develop programs.
Most commonly used computer
language: C, C++, Java, C#,
Visual Basic, Fortran
61
62
Gadgets
(small
programs; you
might see
additional or
different
gadgets on
your screen)
Start button
Taskbar
Quick Launch toolbar
computer tasks
Examples: web browsers,
Microsoft Office, DBMS,
Security Threats:viruses
Pops up ads
Keylogger: steals personal
information
Creates a back-door and lets
remote users access your
computer
A bad virus spreads very fast
and affects millions computers.
66
attachments
Infected disks and CDs
Worst incidents: Melissa, ILOVEYOU
67
Security Threats:Anti-virus
Firewall
Stop unwanted and unsolicited
incoming network messages and data.
Can be either hardware or software.
Antivirus software
Every computer must equip with an
antivirus software.
System and software update:
Automatic update
Security Threats:Antivirus
Microsoft: security_essentials (free)
Paid: Norton, MacAfee, Trend Micro
Free:
ClamAV: open source. For Unix/Linux ,
69
Security Threats:Antivirus
There is no excuse not to install
an antivirus software, at least it
should have security_essential
installed from
www.microsoft.com/security_ess
ential
SE is free and works well!
70
Security Threats:Phishing
Phishing
number to deposit
Over-payment scam
Security Threats:Phishing
Too good to be true >>> not true
Never open an unsolicited email,
Security Threats:Phishing
To clear a bank check needs one
75
Security Threats:Encryption
Encrypt important files
language
Second generation:
Assembly language
Third generation: High level
such as C, Fortran, C++,
Java, VB
Introduction to Programming
Programming languages
First generation: machine language:
Consists of 0s and 1s
The only language understood by computers
Fast and efficient
Very hard to program, read and understand.
Used in the old times.
79
Introduction to Programming
Programming languages
Second generation: assembly language:
English words are used in a very cryptic way
Needs an assembler to convert it to machine
language
Relatively fast and efficient
Still hard to program, read and understand; but is
doable. The core parts of OSs are usually coded in
assembly language
Different hardware (CPUs) has different assemblers
80
Introduction to Programming
Programming languages
Third generation: high level language:
C, C++, Java, C#,VB, Fortran,
English-like language
Developing programs by writing source code
Source code (compiler or interpreter) assembly
language (assembler) machine language
Still fast and efficient for most tasks
Relatively easy to program, read and understand
Portable to almost all platforms.
81
Translating Languages
English: Display the sum of A times B plus C.
Assembly Language:
mov eax,A
mul B
add eax,C
call WriteInt
82
83
Introduction to Programming
An example
To calculate the average of two
numbers
84
Introduction to Programming
Compiler and Interpreter
Compiler converts the whole program from source
Introduction to Programming
Write a fast program
The slowest part of a program is I/O:
Reduce I/O times as much as possible
Use buffers to do I/O
Gb)
Good video card if you like to play fast games
88
In a distributed environment
A server provides services
A client requests services
The opposite: peer-to-peer
system.
operations,
Code structs: decisions,
loops, functions
Data structures: arrays,
classes, and others.
(1024) bytes
Megabyte (MB) = one million (1024
KB) bytes
Gigabyte (GB) = one billion bytes
Terabyte (TB) = one trillion bytes
D ata Representations
Everything is a number in the
Character Storage
Character sets
Standard ASCII (0 127)
Extended ASCII (0 255)
ANSI
Unicode
(0 255)
(0 65,535)
99